Socket communications

Jp Calderone exarkun at
Fri Jan 17 20:56:10 CET 2003

On Fri, Jan 17, 2003 at 07:57:51AM -0800, Will Stuyvesant wrote:
> [Jp Calderone]
> > Twisted makes implementing this kind of protocol trivial.
> > 
> > (Untested code)
> > ...
> Posting untested code is a demonstration of how much confidence you
> have in the modules you use.  

  It could just be that I was too lazy to take the time to test it, too. ;)

> But your example could use some
> what does ``reactor`` do, and how about
> ``protocol``.

  Indeed!  In brief: transports (never explicitly used in the example) move
bytes around; protocols are given bytes and have the job of making sense of
them; factories instantiate new protocol objects when new connections are
made, and handle cleanup when they are lost; the reactor drives everything,
it is used to start servers listening and clients connecting, and contains
the mainloop function - - the only function in Twisted that
blocks for any length of time.  For more details, these urls might be

> Another thing is that on first sight your code is going to crash on an
> "unknown identifier ``port``" error but that one should be just an
> integer for the port number I guess.

  Yep.  host was left undefined (though commented out) as well ;)  Filling
these in is left as an exercise for the reader.


        "I quite agree with you," said the Duchess; "and the moral of
that is -- Be what you would seem to be' -- or, if you'd like it put
more simply -- Never imagine yourself not to be otherwise than what it
might appear to others that what you were or might have been was not 
otherwise than what you had been would have appeared to them to be
otherwise.'"       -- Lewis Carrol, "Alice in Wonderland"
 12:00am up 32 days, 9:48, 5 users, load average: 0.18, 0.15, 0.16
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list