Thanks for the feedback on this Matheus and Michael. I think I have a good idea now of what I need to do. The point about whether or not you can call async_write before the first one has completed seems important. Right now, I've only got one thread calling io_service.run(), and only 1 thread calling async_write, so it sounds like I don't have to wait, nor do I need to queue, but I do need to manage the buffers' lifetime properly. - Alex
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Michael Caisse Sent: Friday, July 17, 2009 3:14 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Using boost::asio::async_write to stream out data
Matheus Araújo Aguiar wrote:
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 -
This is true if you have only called io_sevice::run from one thread. If you have multiple threads processing events you will have issues because each thread may be writing to the socket at the same time. This would not be a TCP layer issue... it would be an application problem.
Best Regards -
--
---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users