TCP server as a Windows service using Python?

David Mitchell djmitchell at spamfree.optushome.com.au
Thu Jan 29 19:11:06 EST 2004


Hello group,

I'm trying to create a TCP server using Python, and I want it to run under
Windows as a service.

Now, I'm fine with building the TCP server using Python - done it lots of
times, and I know there's lots of sample code out there I can grab if I
ever need to.

Equally, I think I've got the simpler concepts about creating Windows
services using Python clear.  I've got the Python Win32 book, worked
through the example code in there and haven't had any real problems with
it.

Where I'm having trouble is with the overlapped I/O call.  When I create a
TCP server, I need to have it sit there waiting for a client
connection.  With a Windows service, it has to sit there waiting for
administrative messages such as e.g. a "stop service" message.  The
example code in the Python Win32 book uses named pipes to do IO -
I'm constrained to using TCP sockets.

I can't see how to let the service accept *either* an incoming TCP client
connection *or* an e.g. "stop service" message.  If someone could point me
to some sample code, I'd greatly appreciate it - Google hasn't been
helpful.

Thanks in advance

Dave M.



More information about the Python-list mailing list