[Twisted-Python] Plain windows sockets and twisted

Daniel Griffin dgriff1 at gmail.com
Sun Jan 17 18:25:35 EST 2010


Hi,

I am using twisted in a cross-platform manner. I have written both the
client and server. The client is twisted and the server uses python threads.
I am using the select reactor and plain old TCP connections. I encode my
messages to JSON to send them.

On Windows I get tons of un-clean connectionlost events, on Mac everything
works perfectly. I am using the same data set in each case.

If I use the threaded server on windows and the twisted client on mac then I
still get tons of errors. 99% of these times these errors happen after the
last dataReceived when the socket should be closed cleanly.

My threaded code is:
        try:
            (clientsocket, address) = serversocket.accept()
        except Exception, e:
            print "Exception ", e, clientsocket
        try:
            p = processrequest()
            p.set_socket(clientsocket)
            p.start()

and in processrequest
self.sock.send_all(my_json_message)
self.sock.close()

Is this the correct behavior for using plain sockets with twisted? Any
reason why this would be perfectly fine on OSX and not Windows? Sorry for
the long email.

Thank you very very much,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100117/302b314b/attachment.htm 


More information about the Twisted-Python mailing list