[Twisted-Python] Re: writing back to the connection is blocking my code

Drew Smathers drew.smathers at gmail.com
Fri Mar 21 10:15:21 EDT 2008

On Fri, Mar 21, 2008 at 8:50 AM, coder_gus <coder_gus at lavabit.com> wrote:
>  How can I send it back to them
>  (having a reference to each client's protocol class) without receiving
>  data, client connecting etc. ?

1. Without receiving data

This is simple.   When a client connects, your protocol can capture
the connection event with connectionMade method on the protocol.
That's when you'll likely store a reference to the protocol instance
on the factory.  If you need to write back to the connection at a
later time, simply call write on the protocol's transport. For
example, a chat server might do something like this:

for c in self.chatters:

I'm guessing that your concern is that write is going to block.  It's not.

2. Client connecting

The client has to connect first - unless you are writing an
application where each participant in the system is known up front -
and you can establish connections with them (no firewalls).

I would suggest rereading these documents carefully - they should
really cover your questions:


Otherwise, you should provide a more detailed explanation of your use case.

\\\\/ // //\/\\\\\\\
\\\/ \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\ /\\\ \\
/ /\\\ /\\\ \\\\\/\

More information about the Twisted-Python mailing list