Utilities and helpers for simulating a network

Class TLSNegotiation Undocumented
Class FakeAddress The default address type for the host and peer of FakeTransport connections.
Class FakeTransport A wrapper around a file-like object to make it behave as a Transport.
Function makeFakeClient Create and return a new in-memory transport hooked up to the given protocol.
Function makeFakeServer Create and return a new in-memory transport hooked up to the given protocol.
Class IOPump Utility to pump data between clients and servers for protocol testing.
Function connect Create a new IOPump connecting two protocols.
Function connectedServerAndClient Connect a given server and client class to each other.
Class ConnectionCompleter A ConnectionCompleter can cause synthetic TCP connections established by MemoryReactor.connectTCP and MemoryReactor.listenTCP to succeed or fail.
Function connectableEndpoint Create an endpoint that can be fired on demand.
Function _factoriesShouldConnect Should the client and server described by the arguments be connected to each other, i.e. do their port numbers match?
def makeFakeClient(clientProtocol):

Create and return a new in-memory transport hooked up to the given protocol.

ParametersclientProtocolThe client protocol to use. (type: IProtocol provider)
ReturnsThe transport. (type: FakeTransport)
def makeFakeServer(serverProtocol):

Create and return a new in-memory transport hooked up to the given protocol.

ParametersserverProtocolThe server protocol to use. (type: IProtocol provider)
ReturnsThe transport. (type: FakeTransport)
def connect(serverProtocol, serverTransport, clientProtocol, clientTransport, debug=False, greet=True):

Create a new IOPump connecting two protocols.

ParametersserverProtocolThe protocol to use on the accepting side of the connection. (type: IProtocol provider)
serverTransportThe transport to associate with serverProtocol. (type: FakeTransport)
clientProtocolThe protocol to use on the initiating side of the connection. (type: IProtocol provider)
clientTransportThe transport to associate with clientProtocol. (type: FakeTransport)
debugA flag indicating whether to log information about what the IOPump is doing. (type: bool)
greetShould the IOPump be flushed once before returning to put the protocols into their post-handshake or post-server-greeting state? (type: bool)
ReturnsAn IOPump which connects serverProtocol and clientProtocol and delivers bytes between them when it is pumped. (type: IOPump)
def connectedServerAndClient(ServerClass, ClientClass, clientTransportFactory=makeFakeClient, serverTransportFactory=makeFakeServer, debug=False, greet=True):

Connect a given server and client class to each other.

ParametersServerClassa callable that produces the server-side protocol. (type: 0-argument callable returning IProtocol provider.)
ClientClasslike ServerClass but for the other side of the connection. (type: 0-argument callable returning IProtocol provider.)
clientTransportFactorya callable that produces the transport which will be attached to the protocol returned from ClientClass. (type: callable taking (IProtocol) and returning FakeTransport)
serverTransportFactorya callable that produces the transport which will be attached to the protocol returned from ServerClass. (type: callable taking (IProtocol) and returning FakeTransport)
debugShould this dump an escaped version of all traffic on this connection to stdout for inspection? (type: bool)
greetShould the IOPump be flushed once before returning to put the protocols into their post-handshake or post-server-greeting state? (type: bool)
Returnsthe client protocol, the server protocol, and an IOPump which, when its pump and flush methods are called, will move data between the created client and server protocol instances. (type: 3-tuple of IProtocol, IProtocol, IOPump)
def _factoriesShouldConnect(clientInfo, serverInfo):

Should the client and server described by the arguments be connected to each other, i.e. do their port numbers match?

ParametersclientInfothe args for connectTCP (type: tuple)
serverInfothe args for listenTCP (type: tuple)
ReturnsIf they do match, return factories for the client and server that should connect; otherwise return None, indicating they shouldn't be connected. (type: None or 2-tuple of (ClientFactory, IProtocolFactory))
def connectableEndpoint(debug=False):

Create an endpoint that can be fired on demand.

ParametersdebugA flag; whether to dump output from the established connection to stdout. (type: bool)
ReturnsA client endpoint, and an object that will cause one of the Deferreds returned by that client endpoint. (type: 2-tuple of (IStreamClientEndpoint, ConnectionCompleter))
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.