bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to detect, disconnected network connection


From: taraben . a
Subject: Re: how to detect, disconnected network connection
Date: Thu, 08 Jan 2004 12:15:50 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3

Many thanks. That solution is working and gives me pendingError.

Adib.
Btw. Ingredible fast answer ;-)

Nick Liebmann wrote:

address@hidden wrote:

Hello,

I have a simple tcp-server program derived from TCPSession.
My problem now is how to detect disconnected sessions.
1. disconnect by client, solved by messages from Wolfgang and
 Christian. Return 0 bytes read.
2. disconnect by unplugging the network cable. HyperTerminal (my
Client on Windows side) detects that the connection lost.

I already tried the bad() function and pendigError. But it seems
everything normal.

btw. What I expect is a excpetion or pendingError.

My server program works under linux.

Many tanks for help,

Adib.



_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-commoncpp


Hi,

I came across this problem too. As far as I know there is no way to tell if
a 'remote' client has just gone away i.e. been switched off, disconnected
without being closed. I dont think Windows can detect it either, however it
will detect if its own network cable is unplugged.

The best you can do on linux is enable keepalives and change some kernel
parameter which modifies the timeout for keepalives.


The default is every 2 hours and waits for 9 failures before deciding a
connection is dead

for debian I use the following two lines in /etc/sysctl.conf

net/ipv4/tcp_keepalive_time = 30
net/ipv4/tcp_keepalive_probes = 3

This sets the keepalives to every 30 seconds, and will close the connection
if 3 keepalives are missed

You must also enable keepalives on your socket.


for a full description of the available variables, see here:

http://ipsysctl-tutorial.frozentux.net/chunkyhtml/tcpvariables.html

If you are not happy to do this is only other solution is to implement a
user-level keepalive system.


Hope this helps

Nick





reply via email to

[Prev in Thread] Current Thread [Next in Thread]