import threading import logging ###################################################################### class Reader(threading.Thread): def __init__(self, clientsock): threading.Thread.__init__(self) self.logger = logging.getLogger("Reader")
#----------------------------------------------------------------- def run(self): self.logger.info("New child %s" % (threading.currentThread().getName())) self.logger.info("Got connection from %s" % (clientsock.getpeername())) #################################################################### # set up a socket to listen for incoming connections from our clients s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((host, port)) s.listen(1) while True: try: clientsock, clientaddr = s.accept() except KeyboardInterrupt: raise except: traceback.print_exc() continue client = Reader(clientsock) client.setDaemon(1) client.start() -- http://mail.python.org/mailman/listinfo/python-list