t.i.t._BaseBaseClient(object) : class documentation

Part of twisted.internet.tcp View Source View In Hierarchy

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

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 (socket.AF_INET, socket.AF_INET6, socket.AF_UNIX) of the underlying socket of this client connection. (type: int)
Instance Variable socketType The socket type constant (socket.SOCK_STREAM or socket.SOCK_DGRAM) of the underlying socket. (type: int)
Instance Variable reactor The class pointed to by _commonConnection should set this attribute in its constructor. (type: twisted.internet.interfaces.IReactorTime, twisted.internet.interfaces.IReactorCore, twisted.internet.interfaces.IReactorFDSet)
Method resolveAddress No summary
Method failIfNotConnected Generic method called when the attemps 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.
Method connectionLost No summary
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. (type: bool)
Class Variable _commonConnection Subclasses must provide this attribute, which indicates the Connection-alike class to invoke __init__ and connectionLost on. (type: type)
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 None)
Instance Variable _closeSocket Subclasses must implement in order to close the socket in response to a terminated connection attempt. (type: 1-argument callable; see _SocketCloser._closeSocket)
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 None.)
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.
addressFamily =
The address family constant (socket.AF_INET, socket.AF_INET6, socket.AF_UNIX) of the underlying socket of this client connection. (type: int)
socketType =
The socket type constant (socket.SOCK_STREAM or socket.SOCK_DGRAM) of the underlying socket. (type: int)
_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. (type: bool)
_commonConnection =
Subclasses must provide this attribute, which indicates the Connection-alike class to invoke __init__ and connectionLost on. (type: type)
_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 None)
_closeSocket =
Subclasses must implement in order to close the socket in response to a terminated connection attempt. (type: 1-argument callable; see _SocketCloser._closeSocket)
_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 None.)
reactor =
The class pointed to by _commonConnection should set this attribute in its constructor. (type: twisted.internet.interfaces.IReactorTime, twisted.internet.interfaces.IReactorCore, twisted.internet.interfaces.IReactorFDSet)
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.
ParameterswhenDoneA 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.
sktThe socket object to use to perform the connection. (type: socket._socketobject)
errorThe error to fail the connection with.
reactorThe reactor to use for this client. (type: twisted.internet.interfaces.IReactorTime)
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.)
ReturnsNone
NoteYou 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 _setRealAddress(self, address): (source)
Set the resolved address of this _BaseBaseClient and initiate the connection attempt.
ParametersaddressDepending 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.
def failIfNotConnected(self, err): (source)
Generic method called when the attemps to connect failed. It basically cleans everything it can: call connectionFailed, stop read and write, delete socket related members.
def stopConnecting(self): (source)
If a connection attempt is still outstanding (i.e. no connection is yet established), immediately stop attempting to connect.
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.
Parametersreasonthe reason that the connection was terminated (type: Failure)
API Documentation for Twisted, generated by pydoctor at 2013-04-03 11:20:05.