Sockets...

Vincent A. Primavera vincent_a_primavera at netzero.net
Wed May 9 07:48:37 EDT 2001


Hello,
	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'?

	Thank you,	
	Vincent A. Primavera

Error:

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')

Program:

# 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))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
conn.close()




More information about the Python-list mailing list