Skip to main content

Module client

Module client 

Source
Expand description

Raw TCP client with optional TLS, suffix framing, heartbeats, and automatic reconnection.

§State management

The client tracks active, reconnecting, disconnecting, and closed states. State changes notify waiting tasks immediately instead of relying only on periodic checks.

§Connection ownership

A controller owns the connection lifecycle. A dedicated reader task passes complete messages to the configured callback, while a dedicated writer task serializes concurrent sends received over a channel.

§Framing and heartbeats

The configured suffix frames the byte stream in both directions. The writer appends it to sent messages and heartbeats, and the reader uses it to split incoming data into complete messages. Heartbeats are optional and run in a separate task.

§Reconnection

The writer buffers messages while reconnecting. A successful reconnect installs the replacement writer, drains that buffer, restarts the reader, and then invokes the configured post-reconnection callback.

Structs§

SocketClient
A suffix-framed TCP client with optional TLS and automatic reconnection.
SocketClientBuilder
Use builder syntax to set the inputs and finish with connect().
SocketReconnectHandle
Cloneable controller handle for requesting one raw socket reconnect.

Type Aliases§

SocketReconnectReplay
Produces protocol messages that must precede buffered application writes after reconnect.