Sockets and SO_KEEPALIVE option (what does it do?)

Started by
1 comment, last by Hoser 20 years, 6 months ago
Just a quick question. What does the SO_KEEPALIVE option do when I enable it? They discuss it in the Windows SDK, but don''t give many details... Thanks
Advertisement
I use KeepAlive on my server side and setsockopt() it on my listen socket. When I get a connection the connection inherets the sock opts I set for the listen socket. Keep alive then polls, given a frequency when you set the sock opt, the connected socket to see if it is still alive. This can detect things like cable pulls where the client silently disappears without broadcasting his intention to terminate the connection. This can prevent network timeouts on connections as well I think.

RandomTask
You can shorten the default timeout delay at which point TCP will send a ''ping'' packet to test the existence of the remote connection. The default is around 2 hours; so setting this delay to smaller value (say 15 minutes) allows a better usage of your sockets.

This topic is closed to new replies.

Advertisement