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

Andrew Bennetts andrew-twisted at puzzling.org
Thu Dec 1 03:45:03 EST 2005

[please don't top-post]

On Thu, Dec 01, 2005 at 04:22:03PM +0800, Xu Ryan wrote:
> Does Client Creator load protocol's "connectionMade" automatically ,
> same as factory?

ClientCreator is just a shortcut for creating the factory and so forth manually.
The event handlers (connectionMade, dataReceived, connectionLost) on the
resulting protocol will be invoked as normal.

So yes, connectionMade will be called (assuming a connection is made, if the
connection fails the Deferred returned from ClientCreator.connectTCP will have
an error instead), but this isn't really anything to do with ClientCreator: once
the connection is established, ClientCreator is not involved.

Experimenting with the example at
might be a good idea.

The source code for ClientCreator is quite simple.  Perhaps it would be worth
reading and understanding that, so you can see how little code is involved.  The
definition of ClientCreator is found in twisted/internet/protocol.py:


More information about the Twisted-Python mailing list