Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Normal TCP Connection is a four way handshake.</p> <p><a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol" rel="nofollow">http://en.wikipedia.org/wiki/Transmission_Control_Protocol</a></p> <p>When you are killing the client the <strong>FIN</strong> segment is sent from the client side to the server and the server protocol stack sends the <strong>ACK</strong>.</p> <p>Here if the server tried to read data, the read call would return a value of 0, so your server program can understand that the peer has closed and normally would close the connection socket after this. This would allow the <strong>FIN</strong> from the server side to be sent and normal 4 way handshake would get completed after the receipt of the last <strong>ACK</strong> from the client side.</p> <p>(Pl read Q 2.1 of <a href="http://www.faqs.org/faqs/unix-faq/socket/" rel="nofollow">http://www.faqs.org/faqs/unix-faq/socket/</a>)</p> <p>But here you are writing data from the server, so the server is getting a <strong>RESET</strong> from the client only after sending data. So you are getting the error after the first send operation that is on the second send.</p> <p>So, pl. try closing the connection from the client side <strong>abruptly</strong> instead of 4 way handsake, by setting the the linger option and timeout to 0, so that you can get a error(may be different from EPIPE) on the first call of send on the server side.(This is not a recommnended practise but only for your understanding in this particular case)</p> <pre><code>Try the following option of nc, nc -L 0 to set the linger option and timeout to 0 </code></pre> <p>(I have not tried this option of nc, pl. check for details in this link <a href="http://docs.oracle.com/cd/E23824_01/html/821-1461/nc-1.html" rel="nofollow">http://docs.oracle.com/cd/E23824_01/html/821-1461/nc-1.html</a>)</p> <p>Example of nc from the above site, </p> <pre><code>Connect to TCP port, send some data and terminate the connection with TCP RST segment (instead of classic TCP closing handshake) by setting the linger option and timeout to 0: $ echo "foo" | nc -L 0 host.example.com 22 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload