
4 May
2011
4 May
'11
10:07 a.m.
Hello. I use boost::asio::buffer to send a message using void Send(const std::string& messageData) { socket.async_write(boost::asio::buffer(messageData), ...); } And encounter "string iterator not dereferencable" runtime error somewhere within io_service' thread. When I create objects' variable to store message data for the buffer: void Send(const std::string& messageData) { this->tempStorage = messageData; socket.async_write(boost::asio::buffer(this->tempStorage), ...); } the error is never occured. std::string (to which messageData is referenced to) is freed almost right after Send() calling - does boost::asio::buffer stores just a reference to object? If so, how can I force it to store the data by value?