|
Boost Users : |
Subject: Re: [Boost-users] Multiple async operations on a socket
From: Kyle Tarplee (Kyle.Tarplee_at_[hidden])
Date: 2009-09-17 09:27:59
So it seems you can not have multiple outstanding async_read_some or async_write_some. This makes since.
Now the thing that doesn't make since is that since a user could easily make such an error and the problem would be hard to track down (for instance it hasn't caused me a problem yet, just wasn't getting the warm fuzzy feeling about what I was doing) why does ASIO's socket not throw an error or behave more like the deadline_timer when one tries to create multiple async_ operations. The deadline_timer kindly cancels the async_wait() when you call expires_fron_now(). It seems like the socket could cancel the previous read/write by calling it's callback with an error like operation_aborted.
Kyle
On Sep 16, 2009, at 2:40 PM, Matheus Araújo Aguiar wrote:
On Wed, Sep 16, 2009 at 4:39 PM, Igor R <boost.lists_at_[hidden]<mailto:boost.lists_at_[hidden]>> wrote:
> I have a boost::asio::ip::tcp::socket that I want to write to. Can I have multiple outstanding async_write() requests for a single socket?
asio::async_write() is a convenience function that calls
socket::async_write_some() multiple times - until all the data is
sent. This means that if you issue multiple asio::async_write's, the
data will be interleaved in most cases.
As for multiple async_write_some(), it will probably work on some
platforms... But note that async_write_some doesn't promise to send
all your data. So you can't "fire and forget" anyway.
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]<mailto:Boost-users_at_[hidden]>
http://lists.boost.org/mailman/listinfo.cgi/boost-users
I had the same doubt, and asked the same think some weeks ago. Here's what helped me figuring out what happens:
- http://archives.free.net.ph/message/20090821.085221.7ccd0f8a.pt-BR.html
- http://www.jetbyte.com/portfolio-showarticle.asp?articleId=44&catId=1&subcatId=2
Regards,
-- Matheus Araújo Aguiar Computer Scientist matheus.pit_at_[hidden]<mailto:matheus.pit_at_[hidden]> <ATT00001..txt>
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