[Twisted-Python] How can a tcp client connect with multi servers?

Andrew Bennetts andrew-twisted at puzzling.org
Fri Dec 2 02:10:52 EST 2005


On Fri, Dec 02, 2005 at 02:47:12PM +0800, Xu Ryan wrote:
> As you saying, reactor handles the events. Can i register new event
> after the event loop running?

Absolutely.  You can, for instance, call connectTCP as many times as you like
while the event loop is running to establish multiple client connections, which
may be concurrent.

You can call listenTCP at any time too, if during the course of running the code
needs to start listening on another TCP port.

And so on.  Most of the reactor methods can be called while the reactor is
running, with a couple of obvious exceptions (e.g. you can't call reactor.run).

Many of the other actions you can take in a Twisted program, like writing to or
disconnecting a transport, are also at some level instructing the reactor to do
something, and again this happens inside the event loop.

-Andrew.





More information about the Twisted-Python mailing list