Subject: Re: Dumb/silly network programming question
From: Christian Biere <email@example.com>
Date: 12/06/2003 17:34:31
Content-Type: text/plain; charset=us-ascii
Paul Goyette wrote:
> How does one tell if a TCP socket has been disconnected without trying
> to write to the socket?
read() should return 0. However, if the kernel of remote machine holds
the connection or rather never send a FIN (or RST(?)) packet the=20
connection will be hold until the timeout kicks in. Have you checked
with tcpdump that the connection gets closed?
If you want to prevent such hanging connection you have to use your
own timeout routine or use KEEPALIVE and reduce it's timeout.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
-----END PGP SIGNATURE-----