newbie socket/thread question
Grant Edwards
grante at visi.com
Fri Mar 8 16:48:56 EST 2002
In article <3C8928E3.4B55769D at hotmail.com>, Ken wrote:
> Hey everyone..
>
> I'm messing around with Python, trying to learn the language, by
> building a simple network chat program that uses threads and sockets.
>
> I'm trying to set it up so that if the server receives a keyboard
> interupt from console, it'll shut everything down. Which seems to work
> fine for the most part. The problem is that after a user connects and
> the server is stopped, the server cannot start up again right away. It
> gets the error:
>
> socket.error: (48, 'Address already in use')
By default you can't reuse a port immediately after it's been
closed -- you have to wait a few minutes just in case there are
any packets from the old connection still wandering around the
network. It could cause problems if those packets from the old
connectionarrive after you've bound a new socket to that
address.
If you want to disable that feature, you need to set the
SO_REUSEADDR option on the socket before you do the bind()
operation.
--
Grant Edwards grante Yow! Inside, I'm already
at SOBBING!
visi.com
More information about the Python-list
mailing list