Fork a SocketServer on NT

Werner Schiendl ws-news at gmx.at
Thu Nov 15 08:11:58 EST 2001


Hi,

I think the threading module provides basic and portable threading.
See the class Thread in there.

if you have a function to handle the connection something like (untested)

def yourHandlerFunction(handlersock, addr):
    pass

import threading
threading.Thread(target=yourHandlerFunction, args=(handlersock,
addr)).start()

should get you started.

hth
Werner

"GT" <guy.theisen at isp.lu> wrote in message
news:e253b770.0111150446.5dc9ef39 at posting.google.com...
> Hi,
>
>   I'm trying to fork a SocketServer on NT. But I don't know how to do
> this. The   os.fork doesn't work on NT. I have this example from the
> Echo_server.py in O'Reilly book "Python for Win32".
>
>     serversock = socket(AF_INET, SOCK_STREAM)
>     serversock.bind((HOST, PORT))
>     serversock.listen(5)
>     print 'socket listening for connections...'
>     while 1:
>         handlersock, addr = serversock.accept()
>
>         #now do something with the handler socket
>         print 'SocketServer connected by', addr
>         data = handlersock.recv(1024)
>
>         handlersock.send(data)
>
>         handlersock.close()
>         print 'SocketServer closed ...'
> Can anyone show me how to solve this  .....
>
> thanks for any help,
>
> GT





More information about the Python-list mailing list