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.

Instance Variable structFormat format used for struct packing/unpacking. Define it in subclass.
Instance Variable prefixLength length of the prefix, in bytes. Define it in subclass, using struct.calcsize(structFormat)
Class Variable MAX_LENGTH Undocumented
Class Variable recvd Undocumented
Method stringReceived Override this for notification when each complete string is received.
Method lengthLimitExceeded Callback invoked when a length prefix greater than MAX_LENGTH is received. The default implementation disconnects the transport. Override this.
Method dataReceived Convert int prefixed strings into calls to stringReceived.
Method sendString Send a prefixed string to the other end of the connection.
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.
Instance Variable _compatibilityOffset the offset within _unprocessed to the next message to be parsed. (used to generate the recvd attribute)

Inherited from Protocol:

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

Inherited from BaseProtocol (via Protocol):

Instance Variable connected Undocumented
Instance Variable transport Undocumented
Method makeConnection Make a connection to a transport and a server.
Method connectionMade Called when a connection is made.

Inherited from _PauseableMixin:

Instance Variable paused Undocumented
Method pauseProducing Undocumented
Method resumeProducing Undocumented
Method stopProducing Undocumented
_unprocessed = (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.
(type: bytes)
structFormat = (source)
format used for struct packing/unpacking. Define it in subclass.
(type: str)
prefixLength = (source)
length of the prefix, in bytes. Define it in subclass, using struct.calcsize(structFormat)
(type: int)
_compatibilityOffset = (source)
the offset within _unprocessed to the next message to be parsed. (used to generate the recvd attribute)
(type: int)
MAX_LENGTH = (source)

Undocumented

(type: int)
recvd = (source)

Undocumented

def stringReceived(self, string): (source)

Override this for notification when each complete string is received.

ParametersstringThe complete string which was received with all framing (length prefix, etc) removed. (type: bytes)
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.

ParameterslengthThe length prefix which was received. (type: int)
def dataReceived(self, data): (source)

Convert int prefixed strings into calls to stringReceived.

def sendString(self, string): (source)

Send a prefixed string to the other end of the connection.

ParametersstringThe string to send. The necessary framing (length prefix, etc) will be added. (type: bytes)
API Documentation for Twisted, generated by pydoctor 21.2.0 at 2021-02-28 21:00:42.