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

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to