Windows NT Service and Sockets

Olaf Meding OlafMeding at compuserve.com
Wed Mar 3 21:10:41 CET 2004


How can I used WaitForMultipleObjects() with sockets?  The code (shown
below) respresents a very simple echo server using sockets.  I need
WaitForMultipleObjects() so I can wait for both a new connection and
the stop command from the service manager.

Your help is greatly appreciated.  Thanks. 

Olaf


    def SvcDoRun(self):
        sock = socket(AF_INET, SOCK_STREAM)
        sock.bind(('localhost', 53574))
        sock.listen(1)
        
        connection, addr = sock.accept()
        data = connection.recv(1024)
        connection.send(data)
        connection.close()
        
        # We do nothing other than wait to be stopped!
        win32event.WaitForSingleObject(self.hWaitStop,
win32event.INFINITE)



More information about the Python-list mailing list