Description
Is your feature request related to a problem? Please describe.
In many cases, unused TCP sessions are left to an ESTABLISHED state, e.g. by a firewall that drops the connection. The server endpoint has no way of identifying the situation if no traffic is sent over the TCP session. TCP keepalives RFC1122, sec. 4.2.3.6 is an existing mechanism that handles this issue and drops unused connections when they are identified.
This happens quite often on the internet with public servers so implementing a keepalive configuration mechanism is justified to avoid unnecessary resource consumption by hanging connections. Socket-level keepalives need to be enabled to be able to use OS-level keepalives.
Describe the solution you'd like
TCP sessions should allow keepalive configuration in general.
Describe alternatives you've considered
The alternative would be to implement some kind of monitoring script or similar that tries to identify unused connections from statistics. In most cases, this kind of heuristics is troublesome to implement correctly. Firewalls, like iptables, do not provide the means to drop unused but valid ESTABLISHED TCP connections.
Additional context
#1075 implements TCP keepalive via configuration (thx!)