select query

Guy Harris guy at rlgvax.UUCP
Wed Jan 30 11:08:57 AEST 1985


> boolean io_haschar(infile)
> FILE *infile;
> ...
>   readfds = (1<<fileno(infile));
>     
>   nfound = select(1, &readfds, 0, 0, &timeout);
> 
>   if (nfound == 0)
> 	return(FALSE);

"fileno(infile)" must be zero for this to work.  I don't have the original
4.2BSD or ULTRIX-32 documentation, so it may be ambiguous on this point,
but my 4.2BSD manual says:

	"Nfds" descriptors are checked, i.e. the bits from 0 through
	"nfds"-1 in the masks are examined.

I.e., "nfds" (the first argument to "select") is not the number of one
bits in all the masks (which is 1 in this case), but the highest bit to
be examined plus one (i.e., 32 is probably a nice number, as it's greater
than the 20 that is usually the size of a descriptor table, and is also
the number of bits in an "int" on machines that are 1) reasonable and 2)
can support 4.2BSD).

> We are running Ultrix-32, and note the following disclaimer in the
> documentation for select(2).
> 
> STATUS
>      SELECT(2) currently is not supported  by  Digital  Equipment
>      Corporation.

*THAT'S* amusing.  I'd be curious to see what they do, and don't, support;
a HECK of a lot of networking code uses "select".

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list