Go to the latest version of this document.

# ``twisted`.`internet`.`unix`.`_SendmsgMixin``

class documentation

`class _SendmsgMixin: (source)`

Known subclasses: `twisted.internet.unix.Client`, `twisted.internet.unix.Server`

View In Hierarchy

Mixin for stream-oriented UNIX transports which uses sendmsg and recvmsg to offer additional functionality, such as copying file descriptors into other processes.

Method | `__init__` | Undocumented
Method | `doRead` | Calls {IProtocol.dataReceived} with all available data and `IFileDescriptorReceiver.fileDescriptorReceived` once for each received file descriptor in ancillary data.
Method | `sendFileDescriptor` | Queue the given file descriptor to be sent and start trying to send it.
Method | `writeSomeData` | Send as much of `data` as possible. Also send any pending file descriptors.
Method | `_ancillaryLevelSOLSOCKETTypeSCMRIGHTS` | Processes ancillary data with level SOL_SOCKET and type SCM_RIGHTS, indicating that the ancillary data payload holds file descriptors.
Method | `_isSendBufferFull` | Determine whether the user-space send buffer for this transport is full or not.
Instance Variable | `_fileDescriptorBufferSize` | An `int` giving the maximum number of file descriptors to accept and queue for sending before pausing the registered producer, if there is one.
Instance Variable | `_sendmsgQueue` | A `list` of `int` holding file descriptors which are currently buffered before being sent.
Instance Variable | `_writeSomeDataBase` | The class which provides the basic implementation of `writeSomeData`. Ultimately this should be a subclass of `twisted.internet.abstract.FileDescriptor`. Subclasses which mix in `_SendmsgMixin` must define this.

def __init__(self): (source)
overridden in `twisted.internet.unix.Client`, `twisted.internet.unix.Server`

Undocumented

def doRead(self): (source)

Calls {IProtocol.dataReceived} with all available data and `IFileDescriptorReceiver.fileDescriptorReceived` once for each received file descriptor in ancillary data.

This reads up to `self.bufferSize` bytes of data from its socket, then dispatches the data to protocol callbacks to be handled. If the connection is not lost through an error in the underlying recvmsg(), this function will return the result of the dataReceived call.

def sendFileDescriptor(self, fileno): (source)

Queue the given file descriptor to be sent and start trying to send it.

def writeSomeData(self, data): (source)

Send as much of `data` as possible. Also send any pending file descriptors.

def _ancillaryLevelSOLSOCKETTypeSCMRIGHTS(self, cmsgData): (source)

Processes ancillary data with level SOL_SOCKET and type SCM_RIGHTS, indicating that the ancillary data payload holds file descriptors.

Calls `IFileDescriptorReceiver.fileDescriptorReceived` once for each received file descriptor or logs a message if the protocol does not implement `IFileDescriptorReceiver`.

Parameters
cmsgData:`bytes` | Ancillary data payload.

def _isSendBufferFull(self): (source)

Determine whether the user-space send buffer for this transport is full or not.

This extends the base determination by adding consideration of how many file descriptors need to be sent using `sendmsg.sendmsg`. When there are more than `self._fileDescriptorBufferSize`, the buffer is considered full.

Returns
`True` if it is full, `False` otherwise.

_fileDescriptorBufferSize: `int` = (source)

An `int` giving the maximum number of file descriptors to accept and queue for sending before pausing the registered producer, if there is one.

_sendmsgQueue: `list` = (source)

A `list` of `int` holding file descriptors which are currently buffered before being sent.

_writeSomeDataBase: `type[FileDescriptor] | None` = (source)

The class which provides the basic implementation of `writeSomeData`. Ultimately this should be a subclass of `twisted.internet.abstract.FileDescriptor`. Subclasses which mix in `_SendmsgMixin` must define this.