[Tutor] More network server questions
Tino Dai
tinoloc at gmail.com
Mon Jun 19 22:35:18 CEST 2006
Hi Everybody,
I took Kent's advice, and used SocketServer instead of rolling my own
sockets. It works pretty good except for the fact that when I exit and
restart the program, I get a Address in use. And I remember that Danny told
me about allow_reuse_address. So, that's where I got stuck. I put in that
statement, but no change. What am I missing?
class FtpServer ( SocketServer.StreamRequestHandler):
def handle(self):
self.allow_reuse_address = 1
self.filename=self.rfile.readline(512)
self.filename=string.strip(self.filename)
while (self.filename != 'exit'):
secQueue.put(self.filename)
Listener.sema.release()
self.filename=self.rfile.readline(512)
self.filename=string.strip(self.filename)
class Listener( threading.Thread ):
sema = threading.Semaphore()
def __init__(self):
self.port=4242
self.ipAddr='140.147.241.58'
self.wholeFilenameList=[]
threading.Thread.__init__(self)
#print "Done with init"
def run(self):
server=SocketServer.TCPServer(('',self.port), FtpServer)
print "The port is: ", self.port
Thanks,
Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060619/57dc6a29/attachment.htm
More information about the Tutor
mailing list