Sockets...
Grant Edwards
grante at visi.com
Wed May 9 13:09:36 EDT 2001
In article <mailman.989423353.4397.python-list at python.org>, Vincent A. Primavera wrote:
> I have been experimenting with a variant of the program listed below from
>the Python Library Reference... I'm getting the error below very frequently.
>How can I prevent this from happening? And when it does happen is there a
>way that I can 'manually' free up the 'socket'?
>Traceback (innermost last):
> File "./server.py", line 37, in ?
> auth()
> File "./server.py", line 17, in auth
> sck.bind((host, port))
>socket.error: (98, 'Address already in use')
A particular port can't be reused for X seconds after it's
closed (for security reasons). X varies from stack to stack.
If you want to be able to re-use it right away, set the
SO_REUSEADDR option:
s = socket(AF_INET, SOCK_STREAM)
s.setsockopt(SOL_SOCKET,SO_REUSEADDR,1)
s.bind(host,port)
s.listen(1)
--
Grant Edwards grante Yow! Yow! Are we wet yet?
at
visi.com
More information about the Python-list
mailing list