|
Boost Users : |
Subject: Re: [Boost-users] Using boost::asio::async_write to stream out data
From: Alex Black (alex_at_[hidden])
Date: 2009-07-17 15:36:44
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_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of
> Michael Caisse
> Sent: Friday, July 17, 2009 3:14 PM
> To: boost-users_at_[hidden]
> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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