A sample Protocol which stores the data passed to it.

Instance Variable packetData a bytes of data to be sent when the connection is made.
Instance Variable data a bytes of the data passed to us.
Instance Variable open True if the channel is open.
Instance Variable reason if not None, the reason the protocol was closed.
Method connectionMade Set up the instance variables. If we have any packetData, send it along.
Method dataReceived Store the received data and write it back with a tilde appended. The tilde is appended so that the tests can verify that we processed the data.
Method connectionLost Close the protocol and store the reason.

Inherited from Protocol:

Method logPrefix Return a prefix matching the class name, to identify log messages related to this protocol instance.

Inherited from BaseProtocol (via Protocol):

Method makeConnection Make a connection to a transport and a server.
packetData =
a bytes of data to be sent when the connection is made.
data =
a bytes of the data passed to us.
open =
True if the channel is open.
reason =
if not None, the reason the protocol was closed.
def connectionMade(self):

Set up the instance variables. If we have any packetData, send it along.

def dataReceived(self, data):

Store the received data and write it back with a tilde appended. The tilde is appended so that the tests can verify that we processed the data.

def connectionLost(self, reason):

Close the protocol and store the reason.

API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.