module documentation
Utilities and helpers for simulating a network
Class |
|
A ConnectionCompleter can cause synthetic TCP connections established by MemoryReactor.connectTCP and MemoryReactor.listenTCP to succeed or fail. |
Class |
|
The default address type for the host and peer of FakeTransport connections. |
Class |
|
A wrapper around a file-like object to make it behave as a Transport. |
Class |
|
Utility to pump data between clients and servers for protocol testing. |
Class |
|
Undocumented |
Function | connect |
Create a new IOPump connecting two protocols. |
Function | connectable |
Create an endpoint that can be fired on demand. |
Function | connected |
Connect a given server and client class to each other. |
Function | make |
Create and return a new in-memory transport hooked up to the given protocol. |
Function | make |
Create and return a new in-memory transport hooked up to the given protocol. |
Function | _factories |
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 | |
serverIProtocol provider | The protocol to use on the accepting side of the connection. |
serverFakeTransport | The transport to associate with serverProtocol. |
clientIProtocol provider | The protocol to use on the initiating side of the connection. |
clientFakeTransport | The transport to associate with clientProtocol. |
debug:bool | A flag indicating whether to log information about what the IOPump is doing. |
greet:bool | Should the IOPump be flushed once before returning to put the protocols into their post-handshake or post-server-greeting state? |
Returns | |
IOPump | An IOPump which connects serverProtocol and clientProtocol and delivers bytes between them when it is pumped. |
Create an endpoint that can be fired on demand.
Parameters | |
debug:bool | A 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 Deferred s 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 | |
IProtocol provider. | a callable that produces the server-side protocol. |
IProtocol provider. | like ServerClass but for the other side of the connection. |
clientIProtocol ) and returning FakeTransport | a callable that produces the transport which will be attached to the protocol returned from ClientClass. |
serverIProtocol ) and returning FakeTransport | a callable that produces the transport which will be attached to the protocol returned from ServerClass. |
debug:bool | Should this dump an escaped version of all traffic on this connection to stdout for inspection? |
greet:bool | Should 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 , IOPump | the 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. |
Create and return a new in-memory transport hooked up to the given protocol.
Parameters | |
clientIProtocol provider | The client protocol to use. |
Returns | |
FakeTransport | The transport. |
Create and return a new in-memory transport hooked up to the given protocol.
Parameters | |
serverIProtocol provider | The server protocol to use. |
Returns | |
FakeTransport | The transport. |
Should the client and server described by the arguments be connected to each other, i.e. do their port numbers match?
Parameters | |
clienttuple | the args for connectTCP |
servertuple | the 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. |