Re: Re: HELP: select() under sockets

Geof Cooper (imagen!apolling!
Tue, 8 Sep 87 10:02:44 pdt

> The definition of the first argument to the socket is the maximum file
> descriptor that can be specified in any of the other fields. You set
> it to one (presumably because you are assuming the value was supposed to
> be the number of things selecting on). Setting this value to one means
> that you can only select on file descriptor 0. Set the value to something
> larger like the maximum number of file descriptors (NFILE).

Umm, I just looked into /usr/include/stdio.h on our apollo system:

    Changelog entry:
        10/01/82 jrw increased _NFILE from 20 to 128.....

So using NFILE is probably NOT the way to go, unless you declare
readfds, et al as arrays (this leads one to wonder, of course, why
the existing apollo software works at all -- since I know of no code
that actually uses arrays with select. Probably because no one actually
opens more than 32 file descriptors and only THEN creates a socket...).

In a separate note to Mr. Widdowson, I suggested:

        min( 8 * (sizeof readfds), NFILE )

so that the argument really does reflect the size of the data
being passed to it. Actually,

        8 * (sizeof readfds)

is probably sufficient, since you will never actually turn on
a bit that is beyond NFILE (hmmm... maybe little-endian vs
big-endian affects things... comments?).

Unfortunately, this is non-portable, since the size of a char is
not necessarily 8 bits. But I suspect that all network software
would break if char != octet.

- Geof

This archive was generated by hypermail 2.0b3 on Thu Mar 09 2000 - 14:39:15 GMT