hvl_ccb.comm.tcp
TCP communication protocol. Makes use of the socket library.
- class Tcp(*args, **kwargs)[source]
Bases:
TcpCommunicationOld name
TcpforTcpCommunicationfor keeping this import backwards compatibile
- class TcpCommunication(configuration)[source]
Bases:
AsyncCommunicationProtocolTcp Communication Protocol.
- static config_cls() type[TcpCommunicationConfig][source]
Return the default configdataclass class.
- Returns:
a reference to the default configdataclass class
- property is_open: bool
Is the connection open?
- Returns:
True for an open connection
- class TcpCommunicationConfig(terminator: bytes = b'\r\n', encoding: str = 'utf-8', encoding_error_handling: str = 'strict', wait_sec_read_text_nonempty: int | float = 0.5, default_n_attempts_read_text_nonempty: int = 10, host: str | IPv4Address | IPv6Address | None = None, port: int = 54321, bufsize: int = 1024, timeout: float | None = 0.2)[source]
Bases:
AsyncCommunicationProtocolConfigConfiguration dataclass for
TcpCommunication.- bufsize: int = 1024
- force_value(fieldname, value)
Forces a value to a dataclass field despite the class being frozen.
NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.
- Parameters:
fieldname – name of the field
value – value to assign
- classmethod keys() Sequence[str]
Returns a list of all configdataclass fields key-names.
- Returns:
a list of strings containing all keys.
- classmethod optional_defaults() dict[str, object]
Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.
- Returns:
a list of strings containing all optional keys.
- port: int = 54321
- classmethod required_keys() Sequence[str]
Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.
- Returns:
a list of strings containing all required keys.
- exception TcpCommunicationError[source]
Bases:
CommunicationErrorError of the TcpCommunication