Skip to content

socket_connector

qoa4ml.connector.socket_connector

Classes

SocketConnector

SocketConnector handles the connection to a TCP socket for sending serialized messages.

Parameters:

Name Type Description Default
config
SocketConnectorConfig

Configuration settings for the socket connector.

required

Attributes:

Name Type Description
config SocketConnectorConfig

The socket connector configuration.

host str

The hostname or IP address to connect to.

port int

The port number to connect to on the host.

Methods:

Name Description
send_report

Send a serialized message over the socket and optionally log the round-trip time.

Functions
__init__(config)

Initialize an instance of SocketConnector.

Parameters:

Name Type Description Default
config SocketConnectorConfig

Configuration settings for the socket connector.

required
send_report(body_message, log_path=None)

Send a serialized message over the socket and optionally log the round-trip time.

Parameters:

Name Type Description Default
body_message str

The message body to be serialized and sent.

required
log_path str

The path to the log file where round-trip time will be recorded, default is None.

None
Notes
  • This method serializes the body_message using the pickle module.
  • It then sends the serialized message to the configured host and port.
  • If log_path is provided, the round-trip time in milliseconds will be recorded in the specified log file.

Raises:

Type Description
ConnectionRefusedError

If the connection to the host is refused.