Tcp.KeepaliveTCP keepalives.
A TCP implementation may send "keep-alives" (empty TCP ACKs with the sequence number set to one less than the current sequence number for the connection) in order to provoke the peer to respond with an ACK of the current sequence number. If the peer doesn't recognise the connection (e.g. because the connection state has been dropped) then it will return a RST; if the peer (or the network in-between) fails to respond to a configured number of repeated probes then the connection is assumed to be lost.
type action = [ | `SendProbewe should send a keep-alive now
*)| `Wait of Duration.tsleep for a given number of nanoseconds
*)| `Closeconnection should be closed
*) ]An I/O action to perform
val alive : stateAn alive connection
val next :
configuration:Tcpip.Tcp.Keepalive.t ->
ns:int64 ->
state ->
action * statenext ~configuration ~ns state returns the action we should take given that we last received a packet ns nanoseconds ago and the new state of the connection
val create :
Tcpip.Tcp.Keepalive.t ->
([ `SendProbe | `Close ] -> unit Lwt.t) ->
tcreate configuration f clock returns a keep-alive timer which will call f in future depending on both the configuration and any calls to refresh
val refresh : t -> unitrefresh t marks the connection t as alive. This should be called when packets are received.