Windows NT Service and Sockets
gandalf at geochemsource.com
Thu Mar 4 15:21:01 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.
> def SvcDoRun(self):
> sock = socket(AF_INET, SOCK_STREAM)
> sock.bind(('localhost', 53574))
> connection, addr = sock.accept()
> data = connection.recv(1024)
> # We do nothing other than wait to be stopped!
It is common to use a different thread for your main program and other
thread(s) to handle service
manager commands. Hint: you can use select.select on the server socket
object to wait for
an incoming connection for a certain amount of time.
More information about the Python-list