21 Jul
2009
21 Jul
'09
11:14 a.m.
boost::asio::async_write(socket_, boost::asio::buffer(replyString, replyString.size()), boost::bind(&session::handle_write, this, boost::asio::placeholders::error));
I generate the replyString to have results from my database query separated with ^ signs (which is used to tokenize the replyString on the client side...)
string replyString="1^";
boost::asio::buffer does not copy your local string, so the string vanishes before the actual async. write takes place. By the way, if you wish to send the whole string, you don't have to pass a size: boost::asio::buffer(replyString) - but the string must be alive until the completion handler is called.