How to reuse TCP listening socket immediately after it was connected at least once?
Дамјан Георгиевски
gdamjan at gmail.com
Sun May 24 07:02:45 EDT 2009
> 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.
This should work, AFAIK you only need to do it before you call .bind(..)
on the accept-ing socket
--
дамјан ( http://softver.org.mk/damjan/ )
Give me the knowledge to change the code I do not accept,
the wisdom not to accept the code I cannot change,
and the freedom to choose my preference.
More information about the Python-list
mailing list