t.i.t.Connection(abstract.FileDescriptor, _SocketCloser) : class documentation

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

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

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

Superclass of all socket-based FileDescriptors.

This is an abstract superclass of all objects which represent a TCP/IP connection based socket.
Instance Variableslogstrprefix used when logging events related to this connection. (type: str )
Method __init__ Undocumented
Method startTLS Initiate TLS negotiation.
Method write Reliably write some data.
Method writeSequence Reliably write a sequence of data.
Method doWrite Called when data can be written.
Method getHandle Return the socket for this connection.
Method doRead Calls self.protocol.dataReceived with all available data.
Method writeSomeData Write as much as possible of the given data to this TCP connection.
Method readConnectionLost Indicates read connection was lost.
Method connectionLost See abstract.FileDescriptor.connectionLost().
Method logPrefix Return the prefix to log with when I own the logging thread.
Method getTcpNoDelay Return if TCP_NODELAY is enabled.
Method setTcpNoDelay Enable/disable TCP_NODELAY.
Method getTcpKeepAlive Return if SO_KEEPALIVE is enabled.
Method setTcpKeepAlive Enable/disable SO_KEEPALIVE.
Method _startTLS Undocumented
Method _closeWriteConnection Undocumented

Inherited from FileDescriptor:

Method writeConnectionLost Indicates write connection was lost.
Method loseConnection Close the connection at the next available opportunity.
Method loseWriteConnection Undocumented
Method stopReading Stop waiting for read availability.
Method stopWriting Stop waiting for write availability.
Method startReading Start waiting for read availability.
Method startWriting Start waiting for write availability.
Method stopConsuming Stop consuming data.
Method resumeProducing Undocumented
Method pauseProducing Undocumented
Method stopProducing Stop producing data.
Method fileno File Descriptor number for select().
Method _postLoseConnection Called after a loseConnection(), when all data has been written.

Inherited from _ConsumerMixin (via FileDescriptor):

Method registerProducer Register to receive data from a producer.
Method unregisterProducer Stop consuming data from a producer, without disconnecting.

Inherited from _SocketCloser:

Method _closeSocket Undocumented
def __init__(self, skt, protocol, reactor=None): (source)
Undocumented
def startTLS(self, ctx, extra): (source)
Initiate TLS negotiation.
ParameterscontextFactoryA context factory (see ssl.py)
def _startTLS(self): (source)
Undocumented
def write(self, bytes): (source)

Reliably write some data.

The data is buffered until the underlying file descriptor is ready for writing. If there is more than self.bufferSize data in the buffer and this descriptor has a registered streaming producer, its pauseProducing() method will be called.
def writeSequence(self, iovec): (source)

Reliably write a sequence of data.

Currently, this is a convenience method roughly equivalent to:
   for chunk in iovec:
       fd.write(chunk)

It may have a more efficient implementation at a later time or in a different reactor.

As with the write() method, if a buffer size limit is reached and a streaming producer is registered, it will be paused until the buffered data is written to the underlying file descriptor.
def doWrite(self): (source)

Called when data can be written.

A result that is true (which will be a negative number or an exception instance) indicates that the connection was lost. A false result implies the connection is still there; a result of 0 indicates no write was done, and a result of None indicates that a write was done.
def getHandle(self): (source)
Return the socket for this connection.
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 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.
def _closeWriteConnection(self): (source)
Undocumented
def readConnectionLost(self, reason): (source)
Indicates read connection was lost.
def connectionLost(self, reason): (source)
See abstract.FileDescriptor.connectionLost().
def logPrefix(self): (source)
Return the prefix to log with when I own the logging thread.
def getTcpNoDelay(self): (source)
Return if TCP_NODELAY is enabled.
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 getTcpKeepAlive(self): (source)
Return if SO_KEEPALIVE is enabled.
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.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:27:37.