
14 Oct
2008
14 Oct
'08
3:57 p.m.
If(!ec && (bytes_transferred != 0))
{
boost::asio::streambuf::const_buffers_type bufs = buf.data();
std::string s(boost::asio::buffers_begin(bufs),boost::asio::buffers_begin(bufs) + bytes_transferred);
<...>
My question is how do I clear the contents of buf before calling async_read_until again.
If you just want to read some text from from streambuf, do not access its data() - instead use standard istream methods, like this (the data you read is removed from the streambuf): std string someString; std::istream(&buf) >> someString; int someStatus; std::istream(&buf) >> someStatus; std::string wholeLine; std::getline(std::istream(&buf), wholeLine); // and so on...