Subject: Re: Dumb/silly network programming question
To: #List NetBSD current users <current-users@NetBSD.ORG>
From: Paul Goyette <>
List: current-users
Date: 12/06/2003 08:39:21
In this case, it's a local connection.

The server side is sitting there in CLOSE_WAIT, which the client side
(the side that got SIGKILLed) goes into FINWAIT_2.  After several
minutes, the FINWAIT_2 session goes away, but CLOSE_WAIT side just sits
there forever (well, at least 15 minutes).

Since the session is using the TELNET protocol, I could just send an
IAC NOP sequence, but that just seems so ugly!

I turned on SO_KEEPALIVE but it didn't timeout the session for at least
3 minutes - how can I reduce the timeout value for SO_KEEPALIVE?

On Sat, 6 Dec 2003, Christian Biere wrote:

> 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
> 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.
> --
> Christian

|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:   |
| Network Engineer | FA29 0E3B 35AF E8AE 6651 |   |
|  & World Cruiser | 0786 F758 55DE 53BA 7731 | |