persistent TCP connection in python using socketserver

markobrien85 at gmail.com markobrien85 at gmail.com
Sat Jan 31 18:31:52 CET 2009


On Jan 30, 5:54 am, Jean-Paul Calderone <exar... at divmod.com> wrote:
> On Thu, 29 Jan 2009 08:38:43 -0800 (PST), markobrie... at gmail.com wrote:
> >G'day
>
> >I'm currentlyusingsocketserverto build a simple XMLSocket (an XML
> >based protocol used for communication between flash and the outside
> >world) server. I've got flash establishing aconnection, sending a
> >request and mypythonserver responding. However at this point
> >socketserverterminates theconnection. Which is bad, since i need a
> >persistentconnectionso i can push data from the server to the client
> >without the overhead of polling.
>
> If you don't want theconnectionto close, then don't let the request
> complete.  SocketServerimplements logic for single request/response
> perconnection.  You can change this by making your requests take a
> really long time (until you're done with theconnection) or you can
> override the behavior which closes theconnectionafter a response.
>
> Or you could use the socket module, on which theSocketServermodule is
> based.  Or you could use Twisted, another higher-level package built on
> the socket module (mostly).  Actually, I recommend Twisted, since it will
> mostly isolate you from boring low-level details and let you implement
> whatever high-level behavior you're after (I know that a bunch of people
> have used it to communicate with Flash, for example).
>
> Jean-Paul

Cheers mate I had a look into twisted but was put off by the FAQ
stating 1.0+ modules may or may not be stable, and only the 'core' is.
I don't wanna be messing around with a potentially buggy server, so im
gonna roll my own using the sockets module.


Thanks for your help !



More information about the Python-list mailing list