Go to the latest version of this document.

# ``twisted`.`internet`.`protocol`.`ClientCreator``

class documentation

`class ClientCreator: (source)`

Constructor: `ClientCreator(reactor, protocolClass, *args, **kwargs)`

View In Hierarchy

Client connections that do not require a factory.

The various connect* methods create a protocol instance using the given protocol class and arguments, and connect it, returning a Deferred of the resulting protocol instance.

Useful for cases when we don't really need a factory. Mainly this is when there is no shared state between protocol instances, and no need to reconnect.

The `connectTCP`, `connectUNIX`, and `connectSSL` methods each return a `Deferred` which will fire with an instance of the protocol class passed to `ClientCreator.__init__`. These Deferred can be cancelled to abort the connection attempt (in a very unlikely case, cancelling the Deferred may not prevent the protocol from being instantiated and connected to a transport; if this happens, it will be disconnected immediately afterwards and the Deferred will still errback with `CancelledError`).

Method | `__init__` | Undocumented
Method | `connectSSL` | Connect to an SSL server.
Method | `connectTCP` | Connect to a TCP server.
Method | `connectUNIX` | Connect to a Unix socket.
Instance Variable | `args` | Undocumented
Instance Variable | `kwargs` | Undocumented
Instance Variable | `protocolClass` | Undocumented
Instance Variable | `reactor` | Undocumented
Method | `_connect` | Initiate a connection attempt.

def __init__(self, reactor, protocolClass, *args, **kwargs): (source)

Undocumented

def connectSSL(self, host, port, contextFactory, timeout=30, bindAddress=None): (source)

Connect to an SSL server.

The parameters are all the same as to `IReactorSSL.connectSSL` except that the factory parameter is omitted.

Returns
A `Deferred` which fires with an instance of the protocol class passed to this `ClientCreator`'s initializer or fails if the connection cannot be set up for some reason.

def connectTCP(self, host, port, timeout=30, bindAddress=None): (source)

Connect to a TCP server.

The parameters are all the same as to `IReactorTCP.connectTCP` except that the factory parameter is omitted.

Returns
A `Deferred` which fires with an instance of the protocol class passed to this `ClientCreator`'s initializer or fails if the connection cannot be set up for some reason.

def connectUNIX(self, address, timeout=30, checkPID=False): (source)

Connect to a Unix socket.

The parameters are all the same as to `IReactorUNIX.connectUNIX` except that the factory parameter is omitted.

Returns
A `Deferred` which fires with an instance of the protocol class passed to this `ClientCreator`'s initializer or fails if the connection cannot be set up for some reason.

args = (source)

Undocumented

kwargs = (source)

Undocumented

protocolClass = (source)

Undocumented

reactor = (source)

Undocumented

def _connect(self, method, *args, **kwargs): (source)

Initiate a connection attempt.

Parameters
method | A callable which will actually start the connection attempt. For example, `reactor.connectTCP`.
*args | Positional arguments to pass to `method`, excluding the factory.
**kwargs | Keyword arguments to pass to `method`.

Returns
A `Deferred` which fires with an instance of the protocol class passed to this `ClientCreator`'s initializer or fails if the connection cannot be set up for some reason.