Here is some supplemental literature on keepalive which explains it in much finer detail.
http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO
Since Java does not allow you to control the actual keepalive times, you can use the examples to change them if you're using a Linux kernel (or proc based OS).