It works now! Igor, you are the best! :)
I'm glad I was helpful.
Conclusion: the program flow must be:
async_write - do smth - write handler called - async write - do smth - ...
Yes, only one async_XXX should be in progress at a time (for the same socket/buffer). The primary problem with multiple async_write's is the following: while async_write guarantees that its handler is invoked only after *all* the data is sent or if an error occurs, it does NOT guarantee that all the buffer is sent at once. Now imagine you issue 2 async_write's: one for a buffer containing "12345678" and another one for "abcdefg". The both will be sent successfully, but your peer might receive the following data: "123ab456cdefg78" - depending on the timing, data-size, and network conditions. As for the problem you encountered - I don't exactly realize how multiple async_write's could cause it, but since fixing the above issue fixed your problem as well, I guess it's not worth investigating it further :).