Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] async write handler is not called until the socket is not closed
From: Igor R (boost.lists_at_[hidden])
Date: 2009-05-02 13:28:42


> 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 :).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net