sholden at holdenweb.com
Wed May 9 18:22:51 CEST 2001
"Vincent A. Primavera" <vincent_a_primavera at netzero.net> wrote in message
news:mailman.989423353.4397.python-list at python.org...
> I have been experimenting with a variant of the program listed below from
> the Python Library Reference... I'm getting the error below very
> How can I prevent this from happening? And when it does happen is there
> way that I can 'manually' free up the 'socket'?
> Thank you,
> Vincent A. Primavera
> Traceback (innermost last):
> File "./server.py", line 37, in ?
> File "./server.py", line 17, in auth
> sck.bind((host, port))
> socket.error: (98, 'Address already in use')
> # Echo server program
> import socket
> HOST = '' # Symbolic name meaning the local host
> PORT = 50007 # Arbitrary non-privileged port
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.bind((HOST, PORT))
> conn, addr = s.accept()
> print 'Connected by', addr
> while 1:
> data = conn.recv(1024)
> if not data: break
I'm not absolutely positive about this: it's a hypothesis.
You close the connection, but not the socket. Without an explicit close it
could be that the TCP port is left in some awaiting timeout state for a
while, depending on the transport layer, before its state data are removed.
An explicit s.close() is unlikely to hurt, I should ahve thought. Let me
know if it helps.
More information about the Python-list