module documentation

Utilities and helpers for simulating a network

Class ConnectionCompleter A ConnectionCompleter can cause synthetic TCP connections established by MemoryReactor.connectTCP and MemoryReactor.listenTCP to succeed or fail.
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.
Class IOPump Utility to pump data between clients and servers for protocol testing.
Class TLSNegotiation Undocumented
Function connect Create a new IOPump connecting two protocols.
Function connectableEndpoint Create an endpoint that can be fired on demand.
Function connectedServerAndClient Connect a given server and client class to each other.
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.
Function _factoriesShouldConnect Should the client and server described by the arguments be connected to each other, i.e. do their port numbers match?
def connect(serverProtocol, serverTransport, clientProtocol, clientTransport, debug=False, greet=True): (source)

Create a new IOPump connecting two protocols.

Parameters
serverProtocol:IProtocol providerThe protocol to use on the accepting side of the connection.
serverTransport:FakeTransportThe transport to associate with serverProtocol.
clientProtocol:IProtocol providerThe protocol to use on the initiating side of the connection.
clientTransport:FakeTransportThe transport to associate with clientProtocol.
debug:boolA flag indicating whether to log information about what the IOPump is doing.
greet:boolShould the IOPump be flushed once before returning to put the protocols into their post-handshake or post-server-greeting state?
Returns
IOPumpAn IOPump which connects serverProtocol and clientProtocol and delivers bytes between them when it is pumped.
def connectableEndpoint(debug=False): (source)

Create an endpoint that can be fired on demand.

Parameters
debug:boolA flag; whether to dump output from the established connection to stdout.
Returns
2-tuple of (IStreamClientEndpoint, ConnectionCompleter)A client endpoint, and an object that will cause one of the Deferreds returned by that client endpoint.
def connectedServerAndClient(ServerClass, ClientClass, clientTransportFactory=makeFakeClient, serverTransportFactory=makeFakeServer, debug=False, greet=True): (source)

Connect a given server and client class to each other.

Parameters
ServerClass:0-argument callable returning IProtocol provider.a callable that produces the server-side protocol.
ClientClass:0-argument callable returning IProtocol provider.like ServerClass but for the other side of the connection.
clientTransportFactory:callable taking (IProtocol) and returning FakeTransporta callable that produces the transport which will be attached to the protocol returned from ClientClass.
serverTransportFactory:callable taking (IProtocol) and returning FakeTransporta callable that produces the transport which will be attached to the protocol returned from ServerClass.
debug:boolShould this dump an escaped version of all traffic on this connection to stdout for inspection?
greet:boolShould the IOPump be flushed once before returning to put the protocols into their post-handshake or post-server-greeting state?
Returns
3-tuple of IProtocol, IProtocol, IOPumpthe 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.
def makeFakeClient(clientProtocol): (source)

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

Parameters
clientProtocol:IProtocol providerThe client protocol to use.
Returns
FakeTransportThe transport.
def makeFakeServer(serverProtocol): (source)

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

Parameters
serverProtocol:IProtocol providerThe server protocol to use.
Returns
FakeTransportThe transport.
def _factoriesShouldConnect(clientInfo, serverInfo): (source)

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

Parameters
clientInfo:tuplethe args for connectTCP
serverInfo:tuplethe args for listenTCP
Returns
None or 2-tuple of (ClientFactory, IProtocolFactory)If they do match, return factories for the client and server that should connect; otherwise return None, indicating they shouldn't be connected.