How to reuse TCP listening socket immediately after it was connected at least once?
Igor Katson
descentspb at gmail.com
Sun May 24 06:46:24 EDT 2009
Igor Katson wrote:
> I have written a socket server and some arbitrary clients. When I
> shutdown the server, and do socket.close(), I cannot immediately start
> it again cause it has some open sockets in TIME_WAIT state. It throws
> address already in use exception at me. I have searched for that in
> google but haven't found a way to solve that.
>
> Tried
> setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> but that does not help.
>
> Is there a nice way to overcome this?
Solved myself. SO_REUSEADDE should be used on the second listening
socket creation (while time_wait already hangs)
More information about the Python-list
mailing list