Subject: Re: Dumb/silly network programming question
To: <>
From: Christian Biere <christianbiere@gmx.de>
List: current-users
Date: 12/06/2003 17:34:31
--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.

--=20
Christian

--rwEMma7ioTxnRzrJ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQE/0gUW0KQix3oyIMcRArG1AKCTfabyKDQLuXWxrpOb8tKho8OaigCgwEco
L/h03vzwONgyG2dUIFdgNo4=
=ud6O
-----END PGP SIGNATURE-----

--rwEMma7ioTxnRzrJ--