Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`pair`.`testing`.`Tunnel``

class documentation

`class Tunnel: (source)`

View In Hierarchy

An in-memory implementation of a tun or tap device.

Method | `__init__` | No summary
Method | `addToReadBuffer` | Deliver a datagram to this tunnel's read buffer. This makes it available to be read later using the `read` method.
Method | `read` | Read a datagram out of this tunnel.
Method | `write` | Write a datagram into this tunnel.
Constant | `EAGAIN_STYLE` | Undocumented
Constant | `EINTR_STYLE` | Undocumented
Constant | `EWOULDBLOCK_STYLE` | Undocumented
Constant | `SEND_BUFFER_SIZE` | Undocumented
Instance Variable | `name` | Undocumented
Instance Variable | `openFlags` | Undocumented
Instance Variable | `pendingSignals` | Undocumented
Instance Variable | `readBuffer` | Undocumented
Instance Variable | `requestedName` | Undocumented
Instance Variable | `system` | Undocumented
Instance Variable | `tunnelMode` | Undocumented
Instance Variable | `writeBuffer` | Undocumented
Property | `blocking` | If the file descriptor for this tunnel is open in blocking mode, `True`. `False` otherwise.
Property | `closeOnExec` | If the file descriptor for this tunnel is marked as close-on-exec, `True`. `False` otherwise.
Constant | `_DEVICE_NAME` | A string representing the conventional filesystem entry for the tunnel factory character special device.

def __init__(self, system, openFlags, fileMode): (source)

Parameters
system | An `_IInputOutputSystem` provider to use to perform I/O.
openFlags:`int` | Any flags to apply when opening the tunnel device. See `os.O_*`.
fileMode | ignored

def addToReadBuffer(self, datagram): (source)

Deliver a datagram to this tunnel's read buffer. This makes it available to be read later using the `read` method.

Parameters
datagram:`bytes` | The IPv4 datagram to deliver. If the mode of this tunnel is TAP then ethernet framing will be added automatically.

def read(self, limit): (source)

Read a datagram out of this tunnel.

Parameters
limit:`int` | The maximum number of bytes from the datagram to return. If the next datagram is larger than this, extra bytes are dropped and lost forever.
Returns
`bytes` | The datagram which was read from the tunnel. If the tunnel mode does not include `TunnelFlags.IFF_NO_PI` then the datagram is prefixed with a 4 byte PI header.
Raises
`OSError` | Any of the usual I/O problems can result in this exception being raised with some particular error number set.
`IOError` | Any of the usual I/O problems can result in this exception being raised with some particular error number set.

def write(self, datagram): (source)

Write a datagram into this tunnel.

Parameters
datagram:`bytes` | The datagram to write.
Returns
`int` | The number of bytes of the datagram which were written.
Raises
`IOError` | Any of the usual I/O problems can result in this exception being raised with some particular error number set.

EAGAIN_STYLE = (source)

Undocumented

Value

    IOError(EAGAIN, 'Resource temporarily unavailable')

EINTR_STYLE = (source)

Undocumented

Value

    IOError(EINTR, 'Interrupted function call')

EWOULDBLOCK_STYLE = (source)

Undocumented

Value

    OSError(EWOULDBLOCK, 'Operation would block')

SEND_BUFFER_SIZE: `int` = (source)

Undocumented

Value

    1024

name = (source)

Undocumented

openFlags = (source)

Undocumented

pendingSignals = (source)

Undocumented

readBuffer = (source)

Undocumented

requestedName = (source)

Undocumented

system = (source)

Undocumented

tunnelMode = (source)

Undocumented

writeBuffer = (source)

Undocumented

@property
blocking = (source)

If the file descriptor for this tunnel is open in blocking mode, `True`. `False` otherwise.

@property
closeOnExec = (source)

If the file descriptor for this tunnel is marked as close-on-exec, `True`. `False` otherwise.

_DEVICE_NAME: `bytes` = (source)

A string representing the conventional filesystem entry for the tunnel factory character special device.

Value

    b'/dev/net/tun'