views:

78

answers:

1

I know it's not safe to manipulated streambuf while async_write working as stated by asio author on boost mailing list. What I want to know is, is it safe to manipulated streambuf after async_read?

Example:

async_read(socket_, recv_streambuf_, ...);
// manipulated while async_read is working
// for example, after I call async_read,
recv_streambuf_.consume(2); 
// or something advance, like this...
int var;
std::istream recv_is(recv_streambuf_);
recv_is >> var; 
+1  A: 

You should be able to do whatever you like with the streambuf when your async_read callback is executed. The callback lets us know when asio is finished using the memory.

skimobear