title: How to deal with a random eof error while reading on a TCP socket using asio?
body: <p><strong>Scenario:</strong></p>
  
  <p>This question is to understand what <a href="https://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio.html#boost_asio.overview.core.streams.why_eof_is_an_error" rel="nofollow noreferrer">EOF error</a> means and how to deal with it.</p>
  
  <p>I have a client and server written using boost asio 1.64. My applications run pretty well for around 3-4 hours where packets are read back and forth like at least 5 packets sent each second by the server and read by the client application.  </p>
  
  <p><strong>Problem and question:</strong></p>
  
  <p>But sometimes after a 5-6 hours, I suddenly recieve an eof error! I am not sure what this means. Did the socket get closed for some reason? Can I ignore it and continue reading the next packet? Should I tried this as a connection loss and "re-trigger my connect to peer" logic?</p>
  
  <p><a href="https://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio.html#boost_asio.overview.core.streams.why_eof_is_an_error" rel="nofollow noreferrer">EOF error</a> states - "The end of a stream can cause read, async_read, read_until or async_read_until functions to violate their contract"? But, there have more than 100,000 reads successful before the error appears. What does this indicate? Expecting for some information and understanding about the <code>eof</code> error from this question.</p>