Boost logo

Boost Users :

Subject: Re: [Boost-users] how to detect TCP communication problems on time with synchronous operations
From: Adam Walling (adam.walling_at_[hidden])
Date: 2010-08-18 21:55:23


For your first problem, is this behavior different from using recv
directly?

In my experience, disconnections can be tricky. A connection can be
silent for a long time yet still be connected. Without a graceful
shutdown, the connection can linger as a zombie. Although this also
makes it possible (theoretically) for the connection to be
reestablished, for the most part that is irrelevant.

The usual answers involve using timeouts or keepalives, either
application-level or socket-level.

This will at least enable your application to detect the abnormal
socket state in a more timely fashion. Note that if you enable
SO_KEEPALIVE, the default timeout will be no less than 2hrs, and
should be modified. I don't believe asio has a portable way to do
this, but there are socket options on posix systems and iocontrol
functions for windows. Docs should lead you in the right direction.

I imagine your second issue is the same; my only suggestion is a
shorter connection timeout.

While it seems logical that the disconnection of the network adapter
would lead to notification of the disconnected sockets, this has never
been the case for me (with Windows at least).

Others may have further insight into these issues as well.

Best of luck,

Adam D. Walling

On Aug 18, 2010, at 8:16 AM, Gözde Bahar KOŞ <gkos_at_[hidden]>
wrote:

> Hello,
>
> I'm using synchronous TCP communication via asio sockets. I have
> following problems:
>
> First problem; When I unplug ethernet cable, "eth0: Link is Down"
> is written in the console, but socket.write_some command does not
> detect link down failure.
>
> Second problem; During socket.connect command, if I plug ethernet
> cable, connect command does not detect this till "Connection timed
> out" error occurs. If I run socket.connect again, it detects the
> connection.
>
> How can I detect these plug/unplug events as soon as the event occurs?
>
> Best Regards,
> Gözde Koş
> ######################################################################
> Dikkat:
>
> Bu elektronik posta mesaji kisisel ve ozeldir. Eger size
> gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.
> Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte,
> guvenlik nedeni ile kontrol edilerek saklanmaktadir. Mesajdaki
> gorusler ve bakis acisi gondericiye ait olup Aselsan A.S. resmi
> gorusu olmak zorunda degildir.
>
> ######################################################################
> Attention:
>
> This e-mail message is privileged and confidential. If you are
> not the intended recipient please delete the message and notify
> the sender. E-mails to and from the company are monitored for
> operational reasons and in accordance with lawful business practices.
> Any views or opinions presented are solely those of the author and
> do not necessarily represent the views of the company.
>
> ######################################################################
> _______________________________________________
> 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