# ``twisted`.`internet`.`iocpreactor`.`abstract`.`FileHandle``

class documentation

`class FileHandle(_ConsumerMixin, _LogOwner): (source)`

Known subclasses: `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

Implements interfaces: `twisted.internet.interfaces.IConsumer`, `twisted.internet.interfaces.IHalfCloseableDescriptor`, `twisted.internet.interfaces.IPushProducer`, `twisted.internet.interfaces.ITransport`

View In Hierarchy

File handle that can read and write asynchronously

Method | `__init__` | Undocumented
Method | `connectionLost` | The connection was lost.
Method | `dataReceived` | Undocumented
Method | `doRead` | Undocumented
Method | `doWrite` | Undocumented
Method | `getFileHandle` | Undocumented
Method | `getHost` | Similar to getPeer, but returns an address describing this side of the connection.
Method | `getPeer` | Get the remote address of this connection.
Method | `loseConnection` | Close the connection at the next available opportunity.
Method | `loseWriteConnection` | Undocumented
Method | `pauseProducing` | Pause producing data.
Method | `readConnectionLost` | Indicates read connection was lost.
Method | `readFromHandle` | Undocumented
Method | `resumeProducing` | Resume producing data.
Method | `startReading` | Undocumented
Method | `startWriting` | No summary
Method | `stopConsuming` | Stop consuming data.
Method | `stopProducing` | Stop producing data.
Method | `stopReading` | Undocumented
Method | `stopWriting` | Undocumented
Method | `write` | Reliably write some data.
Method | `writeConnectionLost` | Indicates write connection was lost.
Method | `writeSequence` | Write an iterable of byte strings to the physical connection.
Method | `writeToHandle` | Undocumented
Constant | `SEND_LIMIT` | Undocumented
Class Variable | `dynamicReadBuffers` | Undocumented
Class Variable | `logstr` | Undocumented
Class Variable | `maxReadBuffers` | Undocumented
Class Variable | `readBufferSize` | Undocumented
Class Variable | `writeBufferSize` | Undocumented
Instance Variable | `connected` | Undocumented
Instance Variable | `dataBuffer` | Undocumented
Instance Variable | `disconnected` | Undocumented
Instance Variable | `disconnecting` | Undocumented
Instance Variable | `offset` | Undocumented
Instance Variable | `producer` | Undocumented
Instance Variable | `producerPaused` | Undocumented
Instance Variable | `reactor` | Undocumented
Instance Variable | `reading` | Undocumented
Instance Variable | `writing` | Undocumented
Method | `_cbRead` | Undocumented
Method | `_cbWrite` | Undocumented
Method | `_closeWriteConnection` | Undocumented
Method | `_dispatchData` | Dispatch previously read data. Return True if self.reading and we don't have any more data
Method | `_handleRead` | Returns False if we should stop reading for now
Method | `_handleWrite` | Returns false if we should stop writing for now
Method | `_resumeReading` | Undocumented
Method | `_resumeWriting` | Undocumented
Instance Variable | `_readBuffers` | Undocumented
Instance Variable | `_readNextBuffer` | Undocumented
Instance Variable | `_readScheduled` | Undocumented
Instance Variable | `_readScheduledInOS` | Undocumented
Instance Variable | `_readSize` | Undocumented
Instance Variable | `_tempDataBuffer` | Undocumented
Instance Variable | `_tempDataLen` | Undocumented
Instance Variable | `_writeDisconnected` | Undocumented
Instance Variable | `_writeDisconnecting` | Undocumented
Instance Variable | `_writeScheduled` | Undocumented

Inherited from `_ConsumerMixin`:

Method | `registerProducer` | Register to receive data from a producer.
Method | `unregisterProducer` | Stop consuming data from a producer, without disconnecting.
Instance Variable | `streamingProducer` | `bool` or `int`

Inherited from `_LogOwner`:

Method | `logPrefix` | Override this method to insert custom logging behavior. Its return value will be inserted in front of every line. It may be called more times than the number of output lines.
Method | `_getLogPrefix` | Determine the log prefix to use for messages related to `applicationObject`, which may or may not be an `interfaces.ILoggingContext` provider.

def __init__(self, reactor=None): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

Undocumented

def connectionLost(self, reason): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

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, data): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`

Undocumented

def doRead(self): (source)
overridden in `twisted.internet.iocpreactor.udp.Port`

Undocumented

def doWrite(self): (source)

Undocumented

def getFileHandle(self): (source)

Undocumented

def getHost(self): (source)
from `twisted.internet.interfaces.ITransport`
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`
Similar to getPeer, but returns an address describing this side of the connection.

Returns
An `IAddress` provider.

def getPeer(self): (source)
from `twisted.internet.interfaces.ITransport`
overridden in `twisted.internet.iocpreactor.tcp.Connection`

Get the remote address of this connection.

Treat this method with caution. It is the unfortunate result of the CGI and Jabber standards, but should not be considered reliable for the usual host of reasons; port forwarding, proxying, firewalls, IP masquerading, etc.

Returns
An `IAddress` provider.

def loseConnection(self, _connDone=failure.Failure(main.CONNECTION_DONE)): (source)
from `twisted.internet.interfaces.ITransport`
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

Close the connection at the next available opportunity.

Call this to cause this FileDescriptor to lose its connection. It will first write any data that it has buffered.

If there is data buffered yet to be written, this method will cause the transport to lose its connection as soon as it's done flushing its write buffer. If you have a producer registered, the connection won't be closed until the producer is finished. Therefore, make sure you unregister your producer when it's finished, or the connection will never close.

def loseWriteConnection(self): (source)

Undocumented

def pauseProducing(self): (source)
from `twisted.internet.interfaces.IPushProducer`

Pause producing data.

Tells a producer that it has produced too much data to process for the time being, and to stop until `resumeProducing()` is called.

def readConnectionLost(self, reason): (source)
from `twisted.internet.interfaces.IHalfCloseableDescriptor`
overridden in `twisted.internet.iocpreactor.tcp.Connection`
Indicates read connection was lost.
def readFromHandle(self, bufflist, evt): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`

Undocumented

def resumeProducing(self): (source)
from `twisted.internet.interfaces.IPushProducer`

Resume producing data.

This tells a producer to re-add itself to the main loop and produce more data for its consumer.

def startReading(self): (source)

Undocumented

def startWriting(self): (source)
overrides `twisted.internet.abstract._ConsumerMixin.startWriting`
Override in a subclass to cause the reactor to monitor this selectable for write events. This will be called once in `unregisterProducer` if `loseConnection` has previously been called, so that the connection can actually close.
def stopConsuming(self): (source)

Stop consuming data.

This is called when a producer has lost its connection, to tell the consumer to go lose its connection (and break potential circular references).

def stopProducing(self): (source)
from `twisted.internet.interfaces.IProducer`

Stop producing data.

This tells a producer that its consumer has died, so it must stop producing data for good.

def stopReading(self): (source)

Undocumented

def stopWriting(self): (source)

Undocumented

def write(self, data): (source)
from `twisted.internet.interfaces.IConsumer`
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

Reliably write some data.

The data is buffered until his file descriptor is ready for writing.

def writeConnectionLost(self, reason): (source)
from `twisted.internet.interfaces.IHalfCloseableDescriptor`
Indicates write connection was lost.
def writeSequence(self, iovec): (source)
from `twisted.internet.interfaces.ITransport`
overridden in `twisted.internet.iocpreactor.tcp.Connection`, `twisted.internet.iocpreactor.udp.Port`

Write an iterable of byte strings to the physical connection.

If possible, make sure that all of the data is written to the socket at once, without first copying it all into a single byte string.

Parameters
iovec | Undocumented
data | The data to write.

def writeToHandle(self, buff, evt): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`

Undocumented

SEND_LIMIT = (source)

Undocumented

Value

    128*1024

dynamicReadBuffers: `bool` = (source)
overridden in `twisted.internet.iocpreactor.udp.Port`

Undocumented

logstr: `str` = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`, `twisted.internet.iocpreactor.tcp.Server`, `twisted.internet.iocpreactor.udp.Port`

Undocumented

maxReadBuffers: `int` = (source)

Undocumented

readBufferSize: `int` = (source)
overridden in `twisted.internet.iocpreactor.udp.Port`

Undocumented

writeBufferSize = (source)

Undocumented

connected: `bool` = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`, `twisted.internet.iocpreactor.tcp.Server`, `twisted.internet.iocpreactor.udp.Port`

Undocumented

dataBuffer = (source)

Undocumented

disconnected: `bool` = (source)

Undocumented

disconnecting: `int` = (source)

Undocumented

offset: `int` = (source)

Undocumented

producer = (source)
overrides `twisted.internet.abstract._ConsumerMixin.producer`

Undocumented

producerPaused: `bool` = (source)
overrides `twisted.internet.abstract._ConsumerMixin.producerPaused`

Undocumented

reactor = (source)
overridden in `twisted.internet.iocpreactor.tcp.Client`

Undocumented

reading: `bool` = (source)

Undocumented

writing: `bool` = (source)

Undocumented

def _cbRead(self, rc, data, evt): (source)

Undocumented

def _cbWrite(self, rc, numBytesWritten, evt): (source)

Undocumented

def _closeWriteConnection(self): (source)
overridden in `twisted.internet.iocpreactor.tcp.Connection`

Undocumented

def _dispatchData(self): (source)
Dispatch previously read data. Return True if self.reading and we don't have any more data
def _handleRead(self, rc, data, evt): (source)
Returns False if we should stop reading for now
def _handleWrite(self, rc, numBytesWritten, evt): (source)
Returns false if we should stop writing for now
def _resumeReading(self): (source)

Undocumented

def _resumeWriting(self): (source)

Undocumented

_readBuffers = (source)

Undocumented

_readNextBuffer: `int` = (source)

Undocumented

_readScheduled = (source)

Undocumented

_readScheduledInOS: `bool` = (source)

Undocumented

_readSize = (source)

Undocumented

_tempDataBuffer: `list` = (source)

Undocumented

_tempDataLen: `int` = (source)

Undocumented

_writeDisconnected: `bool` = (source)

Undocumented

_writeDisconnecting: `bool` = (source)

Undocumented

_writeScheduled = (source)

Undocumented