title: Getting disconnection notification using TCP Keep-Alive on write blocked socket
body: <p>I use TCP Keep-Alive option to detect dead connection. It works well with connection that use reading sockets:</p>
  
  <pre><code>setsockopt(mysock,...) // set various keep alive options
  
  epoll_ctl(ep,mysock,{EPOLLIN|EPOLERR|EPOLLHUP},)
  epoll_wait -&gt; (exits after several seconds when remove host disconnects cable)
  </code></pre>
  
  <p>Epoll wait exits with EPOLLIN|EPOLLHUP on socket without a problem.</p>
  
  <p>However if I try to write a lot to socket till I get EAGAIN and then poll for both reading and writing I don't get a error when I disconnect the cable:</p>
  
  <pre><code>setsockopt(mysock,...) // set various keep alive options
  
  while(send() != EAGAIN)
     ;
  epoll_ctl(ep,mysock,{EPOLLIN|EPOLLOUT|EPOLERR|EPOLLHUP},)
  epoll_wait -&gt; --- Never exits!!!! even when the cable of the remove host is disconnected!!!
  </code></pre>
  
  <ul>
  <li>How can this be solved?</li>
  <li>Have anybody seen a similar problem?</li>
  <li>Any possible direction?</li>
  </ul>
  
  <p><strong>Edit:</strong> Additional Information</p>
  
  <p>When I monitor the communication with wireshark, in the first case (of reading) I get once in several seconds request for ack. But in the second case I don't detect ones at all.</p>