home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.protocols.tcp-ip      TCP and IP network protocols.      14,669 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 13,405 of 14,669   
   Jorgen Grahn to David Schwartz   
   Re: Can accept() block when the listener   
   19 Feb 10 12:08:28   
   
   bfaacba5   
   From: grahn+nntp@snipabacken.se   
      
   On Fri, 2010-02-19, David Schwartz wrote:   
   > On Feb 18, 11:57 pm, Jorgen Grahn  wrote:   
   >   
   >> A short TCP question: if I have a listening (server) socket, and   
   >> select says it is readable, can I call accept() on it and expect it   
   >> not to block, even if the client/peer host/network dies at that very   
   >> moment?   
   >   
   > Nope. Just because it *was* readable doesn't mean it *is* readable.   
   >   
   >> The three-way handshake is supposed to be finished by the time select   
   >> says the listener is readable, isn't it?  Then accept() shouldn't have   
   >> to block.  I was somehow thinking accept triggered the last 2/3 of the   
   >> handshake, and thus might have to wait for RTT and retransmissions.   
   >   
   > No, but what can happen is that the other end can complete the three-   
   > way handshake and then RST the connection. The implementation does not   
   > have to return a dead connection to you (and what would be the point   
   > of it doing so?).   
      
   The point would be to help preserve the non-blocking guarantee I   
   mentioned. ("Return a dead connection" would of course translate to   
   accept() failing immediately with ECONNRESET or something like that.)   
      
   But you have a good point. Is it commonly/always implemented as you   
   describe it, or is it just a possible implementation?  E.g. would I   
   see it on Linux if I wrote a small example?   
      
   /Jorgen   
      
   --   
     // Jorgen Grahn    O  o   .   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca