Did you try setting SO_KEEPALIVE socket option using Socket.setKeepAlive(boolean)? That what its for. The timeout may be really long though (sbout 2 hours), but may be tuned on OS level (globally).
On linux, you can use sysctl (/etc/sysctl.conf): net/ipv4/tcp_keepalive_time = <number of seconds to send probe> net/ipv4/tcp_keepalive_probes = <number of failed probes to kill connection> Or use /proc to configure directly: /proc/sys/net/ipv4/tcp_keepalive_time /proc/sys/net/ipv4/tcp_keepalive_probes For Win XP: http://support.microsoft.com/default.aspx?scid=kb;EN-US;314053 For Win NT/2K, see KeepAliveTime and KeepAliveInterval here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;120642 For Win 95/98/Me: http://support.microsoft.com/default.aspx?scid=kb;en-us;158474 Also note, unplugging a network cable does not mean the TCP connection is disconnected. TCP does not track the state of the transport media in any way. You can unplug the cable, plug it back and happily continue.
signature.asc
Description: OpenPGP digital signature
