Archived

This topic is now archived and is closed to further replies.

Hoser

Sockets and SO_KEEPALIVE option (what does it do?)

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites