[Twisted-Python] Re: Example for a new protocol over TCP

Matthieu Brucher matthieu.brucher at gmail.com
Wed Jun 25 15:01:41 EDT 2008


>> - initialization of the messenger
>> - when building the messenger, I create a DeferredList (or something like
>> that)
>> - when sending a message, I call a send() method that will either add
>> the message to the DeferredList or directly send() is the DeferredList
>> was processed.
>> - when the initialization is complete, the DeferredList is processed.
>
> These parts, I don't understand.

Thanks for the answer ;) I've already printed and read the complete
tutorial, but I may have missed something.

In my application, I have a pool of peer addresses and I may have
another pool of peer connections (other clients/peers may have
connected to my own TCP server or I'm already connected to them, this
would be handled by the factory). Then I want to send a message to one
of the peers though one of its addresses in the pool (this will even
get harder, as there may be different servers listening to different
interfaces, I don't know if twisted manages this). For this purpose,
I'd like to have something like:

>>> self.get_messenger(peer_address).send(message)

This would look for a connection to this peer address in the peer
connections pool if it is already available, or it will try to connect
to the remote peer address. As it is not a simple TCP connection,
before sending the actual message, several protocol messages are sent
from the client to the server and vice-versa. Only then, when those
messages are exchanged, I can actually send the real message to the
remote peer.

Is it more clear ? It may not be the simplest way of doing stuff, but
the principle behond the protocols I use (which are already
impelemnted in C and Java) is to hide the connection to a remote peer,
and to have a message queue, so twisted seems to be the best tool for
this.

Cheers,
Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher




More information about the Twisted-Python mailing list