29 Jun
2007
29 Jun
'07
12:43 p.m.
On 6/29/07, Andrej van der Zeewrote: > > What do you mean with a long-running read operation? A read operation that waits indefinitely for any data the server might send. In my setup, the client only writes data to the > server. Should I start a thread with a synchronous > asio::read on the socket? You could, but... Or can I do this with an > asio::asyn_read too? async_read() is better because you don't have to spawn another thread :) Is this possible while writing > over the same socket at the same time? > Yes it is. Thanks, > Andrej I recommend you join the asio-users mailing list here: https://lists.sourceforge.net/lists/listinfo/asio-users I'm not sure if Chris checks boost-users that often, and he is much better at answering questions! Richard --- Richard Dingwall wrote: > > > On 6/29/07, Cliff Green > > wrote: > > > > > > Andrej van der Zee wrote: > > > > I was wondering how I can find out with ASIO > > whether a > > > > connection is broken. I have a client connected > > to the > > > > server that continuously streams data. > > > > > > The canonical way to consistently detect broken > > TCP > > > connections is to always have a read on the socket > > - it > > > will return 0 on broken connection (in usual BSD > > sockets > > > type reads - I would expect an appropriate error > > parameter > > > set in ASIO). Since you're doing async operations > > this is > > > pretty easy. > > > > > > Many times a write will only buffer the data (at > > the OS / > > > TCP driver level), and an error is not detected > > until a > > > later write (and if the client socket is in a > > "half > > > shutdown" mode, it might be quite a while before > > the TCP > > > keepalive timer pops and the socket is fully > > destroyed). > > > > > > This is absent special ASIO capabilities - if ASIO > > is > > > doing a read "on your behalf", then the problem is > > the > > > "not completely destroyed connection", which is an > > OS / > > > TCP "feature" and nothing that ASIO can help with. > > I > > > haven't found specific details relating to this in > > ASIO, > > > but that may only be because I haven't read enough > > of the > > > ASIO documentation. > > > > > > Chris K (or others), clarifications, corrections, > > or > > > comments? > > > > > > You test for a disconnection with Asio the same way > > you would with BSD > > sockets - you need to leave a long-running read > > operating going. > > > > Check out this post from the Asio-users mailing > > list: > > > http://osdir.com/ml/lib.boost.asio.user/2006-11/msg00035.html > > > > Richard > > > > Cliff > > > > > > _______________________________________________ > > > Boost-users mailing list > > > Boost-users@lists.boost.org > > > > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users > > > > > > _______________________________________________ > > Boost-users mailing list > > Boost-users@lists.boost.org > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users > > > > ___________________________________________________________ > Yahoo! Answers - Got a question? Someone out there knows the answer. Try > it > now. > http://uk.answers.yahoo.com/ > _______________________________________________ > Boost-users mailing list > Boost-users@lists.boost.org > http://lists.boost.org/mailman/listinfo.cgi/boost-users >