title: Writing on a TCP socket closed by the peer
body: <p>I have a client-server application where each side communicate with the other via TCP socket.</p>
  
  <p>I properly establish the connection and then I crash the server BEFORE any data is written on the socket by the client.<br>
  What I see is that the first <code>write()</code> attempt (client-side) is successful and it returns the actual number of written bytes, while the following ones return (as I expected) <code>-1</code> (receiving a <code>SIGPIPE</code>) and <code>errno=EPIPE</code>.</p>
  
  <p>Why the first <code>write()</code> is successful even if the socket is already closed?</p>
  
  <p><strong>EDIT</strong>
  Sometimes also the following <code>write()</code> have a positive return values, as if everything goes well.</p>