Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`tcp`.`_BaseBaseClient``

class documentation

`class _BaseBaseClient: (source)`

Known subclasses: `twisted.internet.iocpreactor.tcp.Client`, `twisted.internet.tcp.BaseClient`

View In Hierarchy

Code shared with other (non-POSIX) reactors for management of general outgoing connections.

Requirements upon subclasses are documented as instance variables rather than abstract methods, in order to avoid MRO confusion, since this base is mixed in to unfortunately weird and distinctive multiple-inheritance hierarchies and many of these attributes are provided by peer classes rather than descendant classes in those hierarchies.

Method | `connectionLost` | Invoked by lower-level logic when it's time to clean the socket up. Depending on the state of the connection, either inform the attached `Connector` that the connection attempt has failed, or inform the connected ...
Method | `failIfNotConnected` | Generic method called when the attempts to connect failed. It basically cleans everything it can: call connectionFailed, stop read and write, delete socket related members.
Method | `resolveAddress` | Resolve the name that was passed to this `_BaseBaseClient`, if necessary, and then move on to attempting the connection once an address has been determined. (The connection will be attempted immediately within this function if either name resolution can be synchronous or the address was an IP address literal...
Method | `stopConnecting` | If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect.
Instance Variable | `addressFamily` | The address family constant (`socket.AF_INET`, `socket.AF_INET6`, `socket.AF_UNIX`) of the underlying socket of this client connection.
Instance Variable | `reactor` | The class pointed to by `_commonConnection` should set this attribute in its constructor.
Instance Variable | `realAddress` | Undocumented
Instance Variable | `socketType` | The socket type constant (`socket.SOCK_STREAM` or `socket.SOCK_DGRAM`) of the underlying socket.
Method | `_finishInit` | Called by subclasses to continue to the stage of initialization where the socket connect attempt is made.
Method | `_setRealAddress` | Set the resolved address of this `_BaseBaseClient` and initiate the connection attempt.
Class Variable | `_commonConnection` | Subclasses must provide this attribute, which indicates the `Connection`-alike class to invoke `__init__` and `connectionLost` on.
Instance Variable | `_closeSocket` | Subclasses must implement in order to close the socket in response to a terminated connection attempt.
Instance Variable | `_collectSocketDetails` | Clean up references to the attached socket in its underlying OS resource (such as a file descriptor or file handle), as part of post connection-failure cleanup.
Instance Variable | `_requiresResolution` | A flag indicating whether the address of this client will require name resolution. `True` if the hostname of said address indicates a name that must be resolved by hostname lookup, `False` if it indicates an IP address literal.
Instance Variable | `_stopReadingAndWriting` | Subclasses must implement in order to remove this transport from its reactor's notifications in response to a terminated connection attempt.

def connectionLost(self, reason): (source)

Invoked by lower-level logic when it's time to clean the socket up. Depending on the state of the connection, either inform the attached `Connector` that the connection attempt has failed, or inform the connected `IProtocol` that the established connection has been lost.

Parameters
reason:`Failure` | the reason that the connection was terminated

def failIfNotConnected(self, err): (source)

Generic method called when the attempts to connect failed. It basically cleans everything it can: call connectionFailed, stop read and write, delete socket related members.

def resolveAddress(self): (source)

Resolve the name that was passed to this `_BaseBaseClient`, if necessary, and then move on to attempting the connection once an address has been determined. (The connection will be attempted immediately within this function if either name resolution can be synchronous or the address was an IP address literal.)

Returns
`None`
Note
You don't want to call this method from outside, as it won't do anything useful; it's just part of the connection bootstrapping process. Also, although this method is on `_BaseBaseClient` for historical reasons, it's not used anywhere except for `Client` itself.

def stopConnecting(self): (source)

If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect.

addressFamily: `int` = (source)

The address family constant (`socket.AF_INET`, `socket.AF_INET6`, `socket.AF_UNIX`) of the underlying socket of this client connection.

reactor: `twisted.internet.interfaces.IReactorTime`, `twisted.internet.interfaces.IReactorCore`, `twisted.internet.interfaces.IReactorFDSet` = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`

The class pointed to by `_commonConnection` should set this attribute in its constructor.

realAddress = (source)
overridden in `twisted.internet.tcp.BaseClient`

Undocumented

socketType: `int` = (source)

The socket type constant (`socket.SOCK_STREAM` or `socket.SOCK_DGRAM`) of the underlying socket.

def _finishInit(self, whenDone, skt, error, reactor): (source)

Called by subclasses to continue to the stage of initialization where the socket connect attempt is made.

Parameters
whenDone | A 0-argument callable to invoke once the connection is set up. This is `None` if the connection could not be prepared due to a previous error.
skt:`socket._socketobject` | The socket object to use to perform the connection.
error | The error to fail the connection with.
reactor:`twisted.internet.interfaces.IReactorTime` | The reactor to use for this client.

def _setRealAddress(self, address): (source)

Set the resolved address of this `_BaseBaseClient` and initiate the connection attempt.

Parameters
address | Depending on whether this is an IPv4 or IPv6 connection attempt, a 2-tuple of `(host, port)` or a 4-tuple of `(host, port, flow, scope)`. At this point it is a fully resolved address, and the 'host' portion will always be an IP address, not a DNS name.

_commonConnection: `type` = (source)

Subclasses must provide this attribute, which indicates the `Connection`-alike class to invoke `__init__` and `connectionLost` on.

_closeSocket: 1-argument callable; see `_SocketCloser._closeSocket` = (source)

Subclasses must implement in order to close the socket in response to a terminated connection attempt.

_collectSocketDetails: 0-argument callable returning `None`. = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`, `twisted.internet.tcp.BaseClient`

Clean up references to the attached socket in its underlying OS resource (such as a file descriptor or file handle), as part of post connection-failure cleanup.

_requiresResolution: `bool` = (source)

A flag indicating whether the address of this client will require name resolution. `True` if the hostname of said address indicates a name that must be resolved by hostname lookup, `False` if it indicates an IP address literal.

_stopReadingAndWriting: 0-argument callable returning `None` = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`, `twisted.internet.tcp.BaseClient`

Subclasses must implement in order to remove this transport from its reactor's notifications in response to a terminated connection attempt.