title: What causes the ENOTCONN error?
body: <p>I'm currently maintaining some web server software and I need to perform a lot of I/O operations. The <code>read()</code>, <code>write()</code>, <code>close()</code> and <code>shutdown()</code> calls, when used on a socket, may sometimes raise an <code>ENOTCONN</code> error. What exactly does this error mean? What are the conditions that would trigger it? I can never seem to reproduce it locally but there are users who can.</p>
  
  <p>Right now I just ignore <code>ENOTCONN</code> when raised by <code>close()</code> and <code>shutdown()</code> because it seems harmless, but I'm not entirely sure.</p>
  
  <p>EDIT:</p>
  
  <ul>
  <li>I am absolutely sure that the <code>connect()</code> call succeeded. I check for its return value.</li>
  <li><code>ENOTCONN</code> is most often raised by <code>close()</code> and <code>shutdown()</code>. I've only very rarely seen a <code>read()</code> and <code>write()</code> raising <code>ENOTCONN</code>.</li>
  </ul>