Using TCP keepalive with Go

1 · Felix Geisendörfer · Aug. 26, 2014, 2:40 p.m.
If you have ever written some TCP socket code, you may have wondered: "What will happen to my connection if the network cable is unplugged or the remote machine crashes?". The short answer is: nothing. The remote end of the connection won't be able to send a FIN packet, and the local OS will not detect that the connection is lost. So it's up to you as the developer to address this scenario. In Go you have several methods available to you that can help with this. Perhaps the first one to consider...