Raft::Transport::TCP
Inherits Raft::Transport < Reference < Object
TCP transport with TLV framing, HMAC-SHA256 authentication, and connection pooling.
Maintains one persistent TCP connection per peer, lazily established on the
first send. Failed connections are retried with exponential backoff
(100ms initial, doubling up to 10s). Inbound connections are authenticated
via Transport::Handshake before any messages are exchanged.
Constructors
Creates a new TCP transport.
- bind_address — local address to listen on (e.g.
"0.0.0.0") - port — local port to listen on; pass
0for OS-assigned (see#actual_port) - peer_addresses — map of peer ID →
{host, port}for outbound connections - cookie — pre-shared key for HMAC-SHA256 mutual authentication; must match all peers
Instance methods
Returns the actual port the server is listening on.
Useful when binding to port 0 (OS-assigned) in tests.
Sends an RPC message to the peer identified by peer_id.
Delivery is best-effort. If the peer is unreachable the message is silently dropped — Raft's protocol-level retries handle the loss.
Starts listening for incoming messages.
Received messages are wrapped in RPC::Envelope (tagged with sender ID)
and pushed into the provided inbox channel.