title: What is the proper mechanism for handling TCP failure?
body: <p>I am writing a socket program in c++. The program runs on a set of cluster machines.</p>
  
  <p>I just entered into the socket programming and just learned how to send and receive. I think that, during the long running of the program, some TCP connections can get lost. In that case, re-connecting the server and client smoothly is necessary. </p>
  
  <p>I wonder if there is a well-known basic mechanism (or algorithm? protocol?) to achieve it. I found that there are many many socket error codes with different semantics, which makes me hard to start.</p>
  
  <p>Can any one suggest any reference code that I can learn from?</p>
  
  <p>Thanks,</p>