Re: SO_LINGER not working?

Steve Wahl (
Thu, 26 Jun 1997 09:48:45 -0500 (CDT)

David S. Miller sez:
> From: Holger Kiehl <>
> Is this a bug or am I doing something wrong?
> You are doing something wrong, you think that zapping time waiters is
> a good idea...
> The server is used to handle lots of connections that disconnect
> very quickly. On Linux I will then have lots of connections in the
> TIME_WAIT state. Is there another solution, other then the
> SO_LINGER option, to avoid connections hanging around in the
> TIME_WAIT state?
> Setting linger to zero to zap time waiters is not only anti-social,
> the various IP working groups state that it is strongly discouraged
> upon, both in the RFC's and elsewhere. The TIME_WAIT state was
> created for a specific purpose, by zapping the socket before the
> TIME_WAIT timeout occurs you are defeating the purpose of it.

(I agree with David on this, as if my opinion was worth
anything... *I* haven't contributed any work to the code :-) )

If you're really that concerned about piled up TIME_WAIT connections:

A possible "solution" to this problem, if you are writing both the
server and the client sides, is to get the client to close his end of
the connection first. If you look at the TCP state diagram, the first
guy to send the FIN (the first end to close) is the one who goes into
TIME WAIT state. I have no idea if Linux follows the RFC here or not
(I have worked on one proprietary TCP stack that mistakenly went to TIME
WAIT from the LAST ACK state).

This means you have to indicate end of transmission in-band, instead
of the handy out-of-band signaling done by the close, so it's probably
not worth it.

--> Steve