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,124 of 14,669   
   Jorgen Grahn to Rob Warnock   
   Re: On implementation of select and poll   
   28 Oct 09 11:27:27   
   
   From: grahn+nntp@snipabacken.se   
      
   On Wed, 2009-10-28, Rob Warnock wrote:   
   > Ripunjay Tripathi   wrote:   
   > +---------------   
   > | I supply a list of lets (say 10) descriptors to select/poll and   
   > | specify a time out value. Now these calls will scan the entire list of   
   > | descriptors for readability or writability as specified. Does the call   
   > | returns before the completion of first scan, if the system call finds   
   > | a condition to be true on a descriptor or an error occurs on any of   
   > | these descriptors ?   
   > +---------------   
   >   
   > Are you asking if "select()" can ever indicate multiple descriptors   
   > in the return value? The answer is "yes", though it may depend upon   
   > the operating system. For example, in FreeBSD "select()" will return   
   > *ALL* of the ready descriptors. From "man 2 select" on FreeBSD 6.2:   
   >   
   >     On return, select() replaces the given descriptor sets with subsets   
   >     consisting of those descriptors that are ready for the requested   
   >     operation.  The select() system call returns the total number of   
   >     ready descriptors in all the sets.   
   >   
   > And in Linux 2.6.18, there is similar language:   
   >   
   >     On success, select() and pselect() return the number of file   
   >     descriptors contained in the three returned descriptor sets   
   >     (that is, the total number of bits that are set in readfds,   
   >     writefds, exceptfds) which may be zero if the timeout expires   
   >     before anything interesting happens.   
   >   
   > So if you're trying to write portable code, you must assume that   
   > *every* scan is "completed", until some scan returns a non-zero   
   > number of ready (and/or error) descriptors (or there is a timeout).   
   > You cannot assume that only the first ready event will be reported.   
      
   Yes, that should be obvious in any select man page.   
      
   I also note that he should not worry that some fds may be ready even   
   though select() didn't report them as ready.  There is nothing he can   
   do about it except what he would do anyway: do his processing of the   
   fds he knows, and then call select() again.   
      
   /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