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,403 of 14,669   
   Barry Margolin to Jorgen Grahn   
   Re: Can accept() block when the listener   
   19 Feb 10 03:44:10   
   
   From: barmar@alum.mit.edu   
      
   In article ,   
    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? Stevens and the Linux man page says so, but only implicitly,   
   > by saying it will block if the fd isn't readable.   
      
   You can't read or write on a listening socket, the only thing you can do   
   with it is accept().   
      
   >   
   > *Thinking*   
   >   
   > 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.   
      
   Your first understanding is correct.  The socket is marked readable and   
   writable after the handshake is complete.   
      
   --   
   Barry Margolin, barmar@alum.mit.edu   
   Arlington, MA   
   *** PLEASE don't copy me on replies, I'll read them in the group ***   
      
   --- 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