class documentation

class IntNStringReceiver(protocol.Protocol, _PauseableMixin): (source)

Known subclasses: twisted.protocols.basic.Int16StringReceiver, twisted.protocols.basic.Int32StringReceiver, twisted.protocols.basic.Int8StringReceiver

View In Hierarchy

Generic class for length prefixed protocols.
Method data​Received Convert int prefixed strings into calls to stringReceived.
Method length​Limit​Exceeded Callback invoked when a length prefix greater than MAX_LENGTH is received. The default implementation disconnects the transport. Override this.
Method send​String Send a prefixed string to the other end of the connection.
Method string​Received Override this for notification when each complete string is received.
Constant MAX​_LENGTH Undocumented
Class Variable recvd Undocumented
Instance Variable prefix​Length length of the prefix, in bytes. Define it in subclass, using struct.calcsize(structFormat)
Instance Variable struct​Format format used for struct packing/unpacking. Define it in subclass.
Instance Variable _compatibility​Offset the offset within _unprocessed to the next message to be parsed. (used to generate the recvd attribute)
Instance Variable _unprocessed bytes received, but not yet broken up into messages / sent to stringReceived. _compatibilityOffset must be updated when this value is updated so that the recvd attribute can be generated correctly.

Inherited from Protocol:

Method connection​Lost Called when the connection is shut down.
Method log​Prefix Return a prefix matching the class name, to identify log messages related to this protocol instance.
Class Variable factory Undocumented

Inherited from BaseProtocol (via Protocol):

Method connection​Made Called when a connection is made.
Method make​Connection Make a connection to a transport and a server.
Instance Variable connected Undocumented
Instance Variable transport Undocumented

Inherited from _PauseableMixin:

Method pause​Producing Undocumented
Method resume​Producing Undocumented
Method stop​Producing Undocumented
Instance Variable paused Undocumented
def dataReceived(self, data): (source)
Convert int prefixed strings into calls to stringReceived.
def lengthLimitExceeded(self, length): (source)
Callback invoked when a length prefix greater than MAX_LENGTH is received. The default implementation disconnects the transport. Override this.
Parameters
length:intThe length prefix which was received.
def sendString(self, string): (source)
Send a prefixed string to the other end of the connection.
Parameters
string:bytesThe string to send. The necessary framing (length prefix, etc) will be added.
def stringReceived(self, string): (source)
Override this for notification when each complete string is received.
Parameters
string:bytesThe complete string which was received with all framing (length prefix, etc) removed.
MAX_LENGTH: int = (source)

Undocumented

Value
99999
recvd = (source)

Undocumented

prefixLength: int = (source)
length of the prefix, in bytes. Define it in subclass, using struct.calcsize(structFormat)
structFormat: str = (source)
_compatibilityOffset: int = (source)
the offset within _unprocessed to the next message to be parsed. (used to generate the recvd attribute)
_unprocessed: bytes = (source)
bytes received, but not yet broken up into messages / sent to stringReceived. _compatibilityOffset must be updated when this value is updated so that the recvd attribute can be generated correctly.