Hi all, Below, you can see a class that when it receives a host connection, it gets validated. Then, if the validation returns True, then process the request. Also, if I want to stop the server, I simply access the self.QuitFlag in lock mode, and set it to 1.
Now that you know what I have, I would like to add SRP functionality to the validation of each new connection. What I need to add to my code to get SRP to work? I don't know where to start. The docs are poor. Thanks Daniel ------------------------------------------------------ class TCPServer(SocketServer.ThreadingTCPServer): def __init__(self,socket,lock): self.socket = socket SocketServer.ThreadingTCPServer.__init__(self, socket,SocketServer.StreamRequestHandler) SocketServer.ThreadingTCPServer.allow_reuse_address = True self.timeout = 0.1 self.lock = lock self.lock.acquire() self.QuitFlag = 0 self.lock.release() def get_request(self): socklist = [self.socket] while 1: # Select with a timeout, then poll a quit flag. An alternate # approach would be to let the master thread "wake us up" # with a socket connection. ready = select.select(socklist, [], [], self.timeout) self.lock.acquire() time_to_quit = self.QuitFlag self.lock.release() if time_to_quit: raise TimeToQuit # Get out now if ready[0]: # A socket was ready to read return SocketServer.ThreadingTCPServer.get_request(self) else: # We timed out, no connection yet pass # Just go back to the select() #Process the request def process_request_thread(self,request,client_address): """ This function gets triggered when the connection is accepted """ pass #Verify the request def verify_request(self,request,client_address): """ This function triggers when some host wants to connect """ if DoValidationOf(client_address): return True else: return False -- http://mail.python.org/mailman/listinfo/python-list