How to change tcp keepalive timer using python script?
You can set the TCP keepalive timers on an already-open socket using setsockopt(). import socket def set_keepalive_linux(sock, after_idle_sec=1, interval_sec=3, max_fails=5): “””Set TCP keepalive on an open socket. It activates after 1 second (after_idle_sec) of idleness, then sends a keepalive ping once every 3 seconds (interval_sec), and closes the connection after 5 failed ping (max_fails), or … Read more