twisted.internet.tcpView Source (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.
|Instance Variable||addressFamily||The address family constant (
|Instance Variable||socketType||The socket type constant (
|Instance Variable||reactor||The class pointed to by
|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||stopConnecting||If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect.|
|Instance Variable||_requiresResolution||A flag indicating whether the address of this client will require name
|Class Variable||_commonConnection||Subclasses must provide this attribute, which indicates the
|Instance Variable||_stopReadingAndWriting||Subclasses must implement in order to remove this transport from its
reactor's notifications in response to a terminated connection attempt. (type: 0-argument callable returning
|Instance Variable||_closeSocket||Subclasses must implement in order to close the socket in response to a
terminated connection attempt. (type: 1-argument callable; see
|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. (type: 0-argument callable returning
|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
socket.AF_UNIX) of the underlying socket of this client connection. (type:
socket.SOCK_DGRAM) of the underlying socket. (type:
Trueif the hostname of said address indicates a name that must be resolved by hostname lookup,
Falseif it indicates an IP address literal. (type:
Connection-alike class to invoke
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 |
|skt||The socket object to use to perform the connection. (type: |
|error||The error to fail the connection with.|
|reactor||The reactor to use for this client. (type: |
Resolve the name that was passed to this
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.)
|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 |
Set the resolved address of this
and initiate the connection attempt.
|Parameters||address||Depending on whether this is an IPv4 or IPv6 connection attempt, a 2-tuple
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.
If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect.
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
the connection attempt has failed, or inform the connected
that the established connection has been lost.
|Parameters||reason||the reason that the connection was terminated (type: |