Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 1996 00:16:39 GMT
From:      James Raynard <fqueries@jraynard.demon.co.uk>
To:        trig@netlink.co.uk
Cc:        questions@FreeBSD.ORG
Subject:   Re: Max first parameter of a Select call?
Message-ID:  <199606190016.AAA00949@jraynard.demon.co.uk>
In-Reply-To: <m0uW4t2-000I5NC@netlink.co.uk> (trig@netlink.co.uk)

next in thread | previous in thread | raw e-mail | index | archive | help
> How do you get the 'select' call in FreeBSD to be happy with something
> greater than 256 as a first parameter?

The first argument to select() specifies the highest-numbered file
descriptor you want select() to check, plus 1. For example, if you
want select() to examine file descriptors 3, 7 and 14, you would have
to pass 15 as the first argument. (A common error is to assume that
the first argument is how many descriptors you want checked - it
isn't!)

> Anything above this seems to give a "Select error 22 - invalid
argument"

As the select() man page explains, things will not work properly if
the first argument is greater than FD_SETSIZE, which is 256 by
default. Hence the EINVAL error.

In any case, the number of file descriptors a process can have open is
limited by OPEN_MAX, which is 64 on FreeBSD:-

$ cat temp.c 
#include <unistd.h>
#include <stdio.h>

int main() {
        printf("The size of the descriptor table is %d.\n", getdtablesize());
        return 0;
}
$ gcc temp.c
$ ./a.out    
The size of the descriptor table is 64.
$

-- 
James Raynard, Edinburgh, Scotland
james@jraynard.demon.co.uk



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606190016.AAA00949>