net: expose TCP keep alive socket option #6214
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
E-help-wanted
Call for participation: Help is requested to fix this issue.
M-net
Module: tokio/net
Currently, Tokio does not expose the keep-alive socket option. There have been attempts (#3082, #3146) but they have not succeeded because keep-alive behavior is not consistent between *nix and windows (possibly others) platforms.
That said, setting the keep-alive option is still a common operation. Today, work arounds exist by using libraries like
socket2
,nix
, orlibc
directly, but we should still add an easier API.Because there is no consistent behavior across platforms, we should consider adding this feature on a platform-by-platform basis. The biggest challenge for doing this is that I am not sure what the best API would be to add platform-specific methods that have the same name but different arguments. E.g.
set_keep_alive
on linux would probably take different arguments than on windows.To move forward with this issue, we would need a proposal for how to add an API with a similar name, but different arguments and behavior based on the platform. This proposal should consider Tokio's existing platform-specific APIs and prior-art within the Rust ecosystem.
The text was updated successfully, but these errors were encountered: