ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If there is an ESTABLISHED TCP socket over any interface, and the underlying interface is brought down (ifconfig <ifname> down), then the TCP keep-alive mechanism comes to rescue (this however requires turning on the SO_KEEPALIVE socket option). The keep-alive mechanism will probe whether the connection is alive or not after keepalive intervals. (configurable through /proc/sys/net/ipv4/tcp_keepalive_*). I have set the probes to 16 and interval as 1.
But if some data is pumped over this socket after bringing the interface down and when the probing mechanism is in progress, then it gets buffered in the TCP send queue and stays there till the connection breaks. My problem is that, in such scenario, the keep alive mechanism takes too long (say 15-20 mins with this configuration) to terminate the connection which would otherwise take a few seconds.
So, can anyone please let me know on how to get rid off the buffered bytes in the send queue and terminate the connection as per the configuration (keep alive probes and timeout interval).
Can you tell us what setting you used for tcp_keepalive_time ? .. this configures how many seconds to wait after the last data packet before sending any probes
The interval has been kept as 1 sec and number of probes as 16. These settings works fine if there is no data sent over the socket when the keep-alive mechanism is in progress. But as I have stated in my last post, as soon as the interface is brought down, some data is immediately sent over it which causes the problem. Hope I've made my point clear.