[Boost-users] [asio] : how to monitor a tcp socket

29 views
Skip to first unread message

Mathieu Peyréga

unread,
Nov 6, 2008, 1:20:24 AM11/6/08
to Boost...@lists.boost.org
Hello

first, thanks to boost creators for these great libraries !

For my question...

I have an external TCP server, to which I connect thanks to a boost.asio
powered client.
I am using asynchronous operations, but i have an issue, I'd like to
trigger a *fast *client side deconnexion when the peer disappear (is
reset for example)
So far, the deconnexion occurs on an error on a asynchronous read
operation, but this error happens like 10-12 seconds after the physical
deconnexion occured.
Is there a way to set the "time out" value ? Is there another way to
detected that the peer vanished.

Regards,

Mathieu

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Igor R

unread,
Nov 6, 2008, 5:32:19 AM11/6/08
to boost...@lists.boost.org
I'm not sure there exists a good portable solution for this.
As for windows platforms, the following article can be useful:
http://tangentsoft.net/wskfaq/newbie.html
(pp. 2.12, 2.13, 2.14)

> I am using asynchronous operations, but i have an issue, I'd like to
> trigger a *fast *client side deconnexion when the peer disappear (is
> reset for example)
> So far, the deconnexion occurs on an error on a asynchronous read
> operation, but this error happens like 10-12 seconds after the physical
> deconnexion occured.
> Is there a way to set the "time out" value ? Is there another way to
> detected that the peer vanished.

Mathieu Peyréga

unread,
Nov 6, 2008, 5:51:53 AM11/6/08
to boost...@lists.boost.org
Igor R a écrit :

> I'm not sure there exists a good portable solution for this.
> As for windows platforms, the following article can be useful:
> http://tangentsoft.net/wskfaq/newbie.html
> (pp. 2.12, 2.13, 2.14)
Thank you for this usefull url...
the bad point is that i don't have access to the server side... so i'll
have to go for a icmp ping monitoring...

i don't know about icmp protocol... does anyone have an example of doing
that with boost.Asio facility ?

regards,

Mathieu
--
http://www.incub.net/

Igor R

unread,
Nov 6, 2008, 5:58:44 AM11/6/08
to boost...@lists.boost.org
I never tried it, but the latest asio supports icmp (see ip::icmp namespace).

> i don't know about icmp protocol... does anyone have an example of doing
> that with boost.Asio facility ?
>

Mathieu Peyréga

unread,
Nov 6, 2008, 12:50:56 PM11/6/08
to boost...@lists.boost.org
I found an alternative solution using an asynchronous timer.
However, it do works only if

m_ReceptionWatchDogTimer.expires_from_now(boost::posix_time::milliseconds(timeout));

with timeout >= 1000

is there a restriction for wait time less than one second ?

regards,

Mathieu


Igor R a écrit :

Igor R

unread,
Nov 6, 2008, 3:08:09 PM11/6/08
to boost...@lists.boost.org
No, I use deadline_timer with timeout values of few milliseconds and
it works very well. Probably some other work that you execute on the
same io_service/thread blocks the timer handler?

> I found an alternative solution using an asynchronous timer.
> However, it do works only if
>
> m_ReceptionWatchDogTimer.expires_from_now(boost::posix_time::milliseconds(timeout));
>
> with timeout >= 1000
>
> is there a restriction for wait time less than one second ?
>

Reply all
Reply to author
Forward
0 new messages