Tcp connections hang on CLOSE_WAIT status Tcp connections hang on CLOSE_WAIT status linux linux

Tcp connections hang on CLOSE_WAIT status


This means that there is unread data left in in the stream, that the client hasn't finished reading.

You can force it off by using the SO_LINGER option. Here's relevant documentation for Linux (also see the option itself, here), and [here's the matching function2] for Win32.

It's the server side that is remaining open, so it's on the server side you can try disabling SO_LINGER.


It may mean that the server hasn't closed the socket. You can easily tell this by using "lsof" to list the file descriptors open by that process which will include TCP sockets. The fix is to have the process always close the socket when it's finished (even in error cases etc)