It's related to my other post. So I am handling a connections that sends me data over time (could be an hour) until it reaches content-length. It response doesn't come all at once. So my logic to handle the above 3 lines of code is to use a while(!done) loop. it's ok to block because this is a listening connection running in a background thread launched from std::async().
Obviously for this loop to be efficient I want to re-use the same stringstreambuf (or streambuf) for reading the body (get_line()). In my mind I would like to be able to clear this buffer (set allocated memory to 0; otherwise future bytes will merge with past bytes; as is happening right now; I simply move write pointer to beginning of buffer). This way when I convert the stream to a std::string (or wstring) it can be processed cleanly. If each line can directly be read to a std:string that would work also for me.
Server sends data like this (as an example; and each line has new line char):
OK
data1
data2
data2
data4
...
END
Thanks,
Obviously for this loop to be efficient I want to re-use the same stringstreambuf (or streambuf) for reading the body (get_line()). In my mind I would like to be able to clear this buffer (set allocated memory to 0; otherwise future bytes will merge with past bytes; as is happening right now; I simply move write pointer to beginning of buffer). This way when I convert the stream to a std::string (or wstring) it can be processed cleanly. If each line can directly be read to a std:string that would work also for me.
Server sends data like this (as an example; and each line has new line char):
OK
data1
data2
data2
data4
...
END
Thanks,