class documentation

class Connection(_TLSConnectionMixin, abstract.FileDescriptor, _SocketCloser, _AbortingMixin): (source)

Known subclasses: twisted.internet.tcp.BaseClient, twisted.internet.tcp.Server

Implements interfaces: twisted.internet.interfaces.ISystemHandle, twisted.internet.interfaces.ITCPTransport, zope.interface.Interface

View In Hierarchy

Superclass of all socket-based FileDescriptors.

This is an abstract superclass of all objects which represent a TCP/IP connection based socket.

Method __init__
Method connection​Lost See abstract.FileDescriptor.connectionLost().
Method do​Read Calls self.protocol.dataReceived with all available data.
Method get​Handle Return the socket for this connection.
Method get​Tcp​Keep​Alive Return if SO_KEEPALIVE is enabled.
Method get​Tcp​No​Delay Return if TCP_NODELAY is enabled.
Method log​Prefix Return the prefix to log with when I own the logging thread.
Method read​Connection​Lost Indicates read connection was lost.
Method set​Tcp​Keep​Alive Enable/disable SO_KEEPALIVE.
Method set​Tcp​No​Delay Enable/disable TCP_NODELAY.
Method write​Some​Data Write as much as possible of the given data to this TCP connection.
Instance Variable logstr prefix used when logging events related to this connection.
Instance Variable protocol Undocumented
Instance Variable socket Undocumented
Method _close​Write​Connection Undocumented
Method _data​Received Undocumented

Inherited from _TLSConnectionMixin:

Constant TLS Undocumented

Inherited from FileDescriptor:

Method do​Write Called when data can be written.
Method fileno File Descriptor number for select().
Method get​Host Similar to getPeer, but returns an address describing this side of the connection.
Method get​Peer Get the remote address of this connection.
Method lose​Connection Close the connection at the next available opportunity.
Method lose​Write​Connection Undocumented
Method pause​Producing Pause producing data.
Method resume​Producing Resume producing data.
Method start​Reading Start waiting for read availability.
Method start​Writing Start waiting for write availability.
Method stop​Consuming Stop consuming data.
Method stop​Producing Stop producing data.
Method stop​Reading Stop waiting for read availability.
Method stop​Writing Stop waiting for write availability.
Method write Reliably write some data.
Method write​Connection​Lost Indicates write connection was lost.
Method write​Sequence Reliably write a sequence of data.
Constant SEND​_LIMIT Undocumented
Class Variable buffer​Size Undocumented
Class Variable disconnecting Undocumented
Instance Variable connected Undocumented
Instance Variable data​Buffer Undocumented
Instance Variable disconnected Undocumented
Instance Variable offset Undocumented
Instance Variable producer Undocumented
Instance Variable producer​Paused Undocumented
Instance Variable reactor Undocumented
Method _is​Send​Buffer​Full Determine whether the user-space send buffer for this transport is full or not.
Method _maybe​Pause​Producer Possibly pause a producer, if there is one and the send buffer is full.
Method _post​Lose​Connection Called after a loseConnection(), when all data has been written.
Class Variable _write​Disconnected Undocumented
Instance Variable _temp​Data​Buffer Undocumented
Instance Variable _temp​Data​Len Undocumented
Instance Variable _write​Disconnecting Undocumented

Inherited from _ConsumerMixin (via FileDescriptor):

Method register​Producer Register to receive data from a producer.
Method unregister​Producer Stop consuming data from a producer, without disconnecting.
Instance Variable streaming​Producer bool or int

Inherited from _LogOwner (via FileDescriptor):

Method _get​Log​Prefix Determine the log prefix to use for messages related to applicationObject, which may or may not be an interfaces.ILoggingContext provider.

Inherited from _SocketCloser:

Method _close​Socket Undocumented
Instance Variable _should​Shutdown Set to True if shutdown should be called before calling close on the underlying socket.

Inherited from _AbortingMixin:

Method abort​Connection Aborts the connection immediately, dropping any buffered data.
Instance Variable do​Write Undocumented
Instance Variable _aborting Set to True when abortConnection is called.
def __init__(self, skt, protocol, reactor=None): (source)
Parameters
sktUndocumented
protocolUndocumented
reactorAn IReactorFDSet provider which this descriptor will use to get readable and writeable event notifications. If no value is given, the global reactor will be used.
def connectionLost(self, reason): (source)
def doRead(self): (source)

Calls self.protocol.dataReceived with all available data.

This reads up to self.bufferSize bytes of data from its socket, then calls self.dataReceived(data) to process it. If the connection is not lost through an error in the physical recv(), this function will return the result of the dataReceived call.

def getHandle(self): (source)
Return the socket for this connection.
def getTcpKeepAlive(self): (source)
Return if SO_KEEPALIVE is enabled.
def getTcpNoDelay(self): (source)
Return if TCP_NODELAY is enabled.
def logPrefix(self): (source)
Return the prefix to log with when I own the logging thread.
def readConnectionLost(self, reason): (source)
def setTcpKeepAlive(self, enabled): (source)

Enable/disable SO_KEEPALIVE.

Enabling SO_KEEPALIVE sends packets periodically when the connection is otherwise idle, usually once every two hours. They are intended to allow detection of lost peers in a non-infinite amount of time.

def setTcpNoDelay(self, enabled): (source)

Enable/disable TCP_NODELAY.

Enabling TCP_NODELAY turns off Nagle's algorithm. Small packets are sent sooner, possibly at the expense of overall throughput.

def writeSomeData(self, data): (source)

Write as much as possible of the given data to this TCP connection.

This sends up to self.SEND_LIMIT bytes from data. If the connection is lost, an exception is returned. Otherwise, the number of bytes successfully written is returned.

logstr: str = (source)
prefix used when logging events related to this connection.
protocol = (source)

Undocumented

socket = (source)

Undocumented

def _closeWriteConnection(self): (source)
def _dataReceived(self, data): (source)

Undocumented