class documentation

class Connection(abstract.FileHandle, _SocketCloser, _AbortingMixin): (source)

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

Implements interfaces: twisted.internet.interfaces.ISystemHandle, twisted.internet.interfaces.ITCPTransport, twisted.internet.interfaces.ITLSTransport, twisted.internet.iocpreactor.interfaces.IReadWriteHandle

View In Hierarchy

Method __init__ Undocumented
Method connection​Lost The connection was lost.
Method data​Received
Method get​Handle Return a system- and reactor-specific handle.
Method get​Host Returns IPv4Address or IPv6Address.
Method get​Peer Returns IPv4Address or IPv6Address.
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 lose​Connection Close the underlying handle or, if TLS has been started, first shut it down.
Method read​Connection​Lost Indicates read connection was lost.
Method read​From​Handle Read into the given buffers from this handle.
Method register​Producer Register a producer.
Method set​Tcp​Keep​Alive Enable/disable SO_KEEPALIVE.
Method set​Tcp​No​Delay Enable/disable TCP_NODELAY.
Method start​TLS
Method unregister​Producer Unregister a producer.
Method write Write some data, either directly to the underlying handle or, if TLS has been started, to the TLSMemoryBIOProtocol for it to encrypt and send.
Method write​Sequence Write some data, either directly to the underlying handle or, if TLS has been started, to the TLSMemoryBIOProtocol for it to encrypt and send.
Method write​To​Handle Send buff to current file handle using _iocp.send. The buffer sent is limited to a size of self.SEND_LIMIT.
Constant TLS False to indicate the connection is in normal TCP mode, True to indicate that TLS has been started and that operations must be routed through the TLSMemoryBIOProtocol instance.
Instance Variable protocol Undocumented
Instance Variable socket Undocumented
Method _close​Write​Connection Undocumented

Inherited from FileHandle:

Method do​Read Undocumented
Method do​Write Undocumented
Method get​File​Handle Undocumented
Method lose​Write​Connection Undocumented
Method pause​Producing Pause producing data.
Method resume​Producing Resume producing data.
Method start​Reading Undocumented
Method start​Writing No summary
Method stop​Consuming Stop consuming data.
Method stop​Producing Stop producing data.
Method stop​Reading Undocumented
Method stop​Writing Undocumented
Method write​Connection​Lost Indicates write connection was lost.
Constant SEND​_LIMIT Undocumented
Class Variable disconnecting Undocumented
Class Variable dynamic​Read​Buffers Undocumented
Class Variable logstr Undocumented
Class Variable max​Read​Buffers Undocumented
Class Variable read​Buffer​Size Undocumented
Class Variable write​Buffer​Size 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
Instance Variable reading Undocumented
Instance Variable writing Undocumented
Method _cb​Read Undocumented
Method _cb​Write Undocumented
Method _dispatch​Data Dispatch previously read data. Return True if self.reading and we don't have any more data
Method _handle​Read Returns False if we should stop reading for now
Method _handle​Write Returns false if we should stop writing for now
Method _resume​Reading Undocumented
Method _resume​Writing Undocumented
Class Variable _write​Disconnected Undocumented
Instance Variable _read​Buffers Undocumented
Instance Variable _read​Next​Buffer Undocumented
Instance Variable _read​Scheduled Undocumented
Instance Variable _read​Scheduled​In​OS Undocumented
Instance Variable _read​Size Undocumented
Instance Variable _temp​Data​Buffer Undocumented
Instance Variable _temp​Data​Len Undocumented
Instance Variable _write​Disconnecting Undocumented
Instance Variable _write​Scheduled Undocumented

Inherited from _ConsumerMixin (via FileHandle):

Instance Variable streaming​Producer bool or int

Inherited from _LogOwner (via FileHandle):

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​Read Undocumented
Instance Variable do​Write Undocumented
Instance Variable _aborting Set to True when abortConnection is called.
def connectionLost(self, reason): (source)

The connection was lost.

This is called when the connection on a selectable object has been lost. It will be called whether the connection was closed explicitly, an exception occurred in an event handler, or the other end of the connection closed it first.

Clean up state here, but make sure to call back up to FileDescriptor.

def dataReceived(self, rbuffer): (source)
def getHandle(self): (source)

Return a system- and reactor-specific handle.

This might be a socket.socket() object, or some other type of object, depending on which reactor is being used. Use and manipulate at your own risk.

This might be used in cases where you want to set specific options not exposed by the Twisted APIs.

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 loseConnection(self, reason=None): (source)
def readConnectionLost(self, reason): (source)
def readFromHandle(self, bufflist, evt): (source)
Read into the given buffers from this handle.
Parameters
bufflist:list of objects implementing the read/write buffer protocolthe buffers to read into
evtan IOCP Event object
Returns
tuple (return code, number of bytes read)
def registerProducer(self, producer, streaming): (source)

Register a producer.

If TLS is enabled, the TLS connection handles this.

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 startTLS(self, contextFactory, normal=True): (source)
def unregisterProducer(self): (source)

Unregister a producer.

If TLS is enabled, the TLS connection handles this.

def write(self, data): (source)
Write some data, either directly to the underlying handle or, if TLS has been started, to the TLSMemoryBIOProtocol for it to encrypt and send.
See Also
twisted.internet.interfaces.ITransport.write
def writeSequence(self, iovec): (source)
Write some data, either directly to the underlying handle or, if TLS has been started, to the TLSMemoryBIOProtocol for it to encrypt and send.
See Also
twisted.internet.interfaces.ITransport.writeSequence
def writeToHandle(self, buff, evt): (source)
Send buff to current file handle using _iocp.send. The buffer sent is limited to a size of self.SEND_LIMIT.
False to indicate the connection is in normal TCP mode, True to indicate that TLS has been started and that operations must be routed through the TLSMemoryBIOProtocol instance.
Value
False
protocol = (source)

Undocumented

socket = (source)

Undocumented

def _closeWriteConnection(self): (source)