3. I understand I can't call async_write again before the first one has
been completed (since I don't want my 8kb chunks interleaved), so should I maintain a queue of buffers waiting to go out?
Correct. You need to check your queue in the completion routine and kick off another async_write if required. I typically use a std::deque to handle this for me. Sometimes just a std::deque< std::string > depending on the application.
Then in my handle_write method should I check the queue, if at least one
buffer is in the queue then I should start a new async_write?
Exactly.
I disagree. I don't have much technical knowledge about how it is done on the O.S layer, but for what i've experienced, you can call several async_write, one after another, without having to wait for the completion of any of the operations. If you call async_write from diferent threads, then data could be interleaved. And with TCP you may get data concatenated, but it has to do with the protocol. Maybe i'm wrong, but for now that's what i think. A third (and fourth, fifth and so on) opinion would be nice. -- Matheus Araújo Aguiar Computer Scientist matheus.pit@gmail.com