pub fn enable_keepalive(sock: &TcpStream) -> Result<()>Expand description
Enable SO_KEEPALIVE on an already-accepted TCP connection.
The one option here applied after the socket exists rather than before it
binds: a server does not construct the sockets it serves, it accepts them.
It still belongs here, because “reach setsockopt without socket2 on the
embedded triples” is the whole reason this module exists, and a keepalive
setter written at a call site would be the third hand-rolled copy of that
twenty lines (epics-tools-rs::procserv::client::set_keepalive is the
second).
The error is returned, not swallowed. C treats this option as required —
create_client calls destroy_client and refuses the connection when it
fails (caservertask.c:1456) — so the caller gets to make C’s decision.
Only the flag is set, which is all C sets. The idle/probe tuning the hosted
CA driver adds through socket2 (epics-ca-rs::server::tcp, 15 s + 5 s) is
deliberately not reproduced: TCP_KEEPIDLE is a Linux spelling, BSD-derived
stacks call it TCP_KEEPALIVE, and neither has been measured on RTEMS or
VxWorks. A target’s default idle is therefore what applies here, as it is in
C.