Reusing Address with Sockets
Mark Rowe
bdash at gmx.net
Mon Nov 11 02:41:04 EST 2002
On Monday, Nov 11, 2002, at 14:58 Pacific/Auckland, Kuros wrote:
> Hello,
>
> I am writing a TCP server program, and everything is working fine,
> except
> for one minor problem. When I close the program, I cannot reuse the
> same
> address, I have to change the port it runs on. Now, I've tried to do
> this:
>
> sock.setsockopt(SO_REUSEADDR, SO_LINGER, 1)
Hello,
That line should be
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
The setsockopt man page details this and other socket options.
Mark
More information about the Python-list
mailing list