二、FreeBSD and MacOS X For the list of available TCP settings (FreeBSD 4.8 an up and 5.4): sysctl -A | grep net.inet.tcp
net.inet.tcp.keepidle - Amount of time, in milliseconds, that the (TCP) connection must be idle
before keepalive probes (if enabled) are sent. net.inet.tcp.keepintvl - The interval, in milliseconds, between keepalive
probes sent to remote machines. After TCPTV_KEEPCNT (default 8)
probes are sent, with no response, the (TCP)connection is dropped. net.inet.tcp.always_keepalive - Assume that SO_KEEPALIVE is set on all TCP
connections, the kernel will periodically send a packet to the remote
host to verify the connection is still up.
therefore formula to calculate maximum TCP inactive connection time is following: net.inet.tcp.keepidle + (net.inet.tcp.keepintvl x 8) the result is in milliseconds. therefore, by setting net.inet.tcp.keepidle = 10000 net.inet.tcp.keepintvl = 5000 net.inet.tcp.always_keepalive =1 (must be 1 always) the system will disconnect a call when TCP connection is dead for: 10000 + (5000 x 8) = 50000 msec (50 sec)
To make system remember these settings at startup, you should add them to /etc/sysctl.conf file
Solaris For the list of available TCP settings: ndd /dev/tcp \? Keepalive related variables: - tcp_keepalive_interval - idle timeout Example: ndd -set /dev/tcp tcp_keepalive_interval 60000 ? 三、Windows Search Knowledge Base for article ID 120642: http://support.microsoft.com/kb/120642/EN-US Basically, you need to tweak some registry entries under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Linux net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_keepalive_probes = 10 net.ipv4.tcp_keepalive_intvl = 30 ? The procedures involving keepalive use three user-driven variables: tcp_keepalive_time the interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive probe; after the connection is marked to need keepalive, this counter is not used any further tcp_keepalive_intvl the interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime tcp_keepalive_probes the number of unacknowledged probes to send before considering the connection dead and notifying the application layer