title: How to detect a TCP socket disconnection (with C Berkeley socket)
body: <p>I am using a loop to read message out from a c Berkeley socket but I am not able to detect when the socket is disconnected so I would accept a new connection. please help</p>
  
  <pre><code>while(true) {
              bzero(buffer,256);
              n = read(newsockfd,buffer,255);
              printf("%s\n",buffer);        
  }
  </code></pre>