title: Debugging a Socket Program
body: <p>I am currently working on a file server in C.</p>
  
  <p>When the client requests a file from the server, it writes to a socket. The server then writes back the data with a header on it. The client reads the header and then reads the actual data. When the client is being debugged, the server terminates the connection before the client has a chance to read the data.</p>
  
  <p>To address this problem, I put in code to write a byte of <code>0</code> to the server when the client is done. The server, has a final read of the socket, looking for that byte but when the client is running under the debugger, it does not wait for the read on the server.</p>
  
  <p>The socket is created with the following call on the server:<br>
           <code>int socketId = socket(AF_INET, SOCK_STREAM, 0);</code></p>
  
  <p>What should I do?</p>