This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: select () confusion
- To: "Trenton D. Adams" <tadams at extremeeng dot com>
- Subject: Re: [ECOS] select () confusion
- From: Jonathan Larmour <jlarmour at redhat dot com>
- Date: Thu, 02 Aug 2001 22:48:56 +0100
- Cc: 'eCos Discussion' <ecos-discuss at sourceware dot cygnus dot com>
- Organization: Red Hat UK Ltd.
- References: <000501c11b9a$14df3310$090110ac@TRENT>
"Trenton D. Adams" wrote:
>
> What does the following statement in the select () function
> documentation mean?
>
> n is the highest-numbered descriptor in any of the three sets, plus 1.
>
> Does that mean I have to figure out what the highest numbered socket
*you are selecting on*
> is
> before calling select?
Yes. Normally you track the largest fd you've ever had, or keep a list of
fds. Or just use FD_SETSIZE if you're lazy IIRC.
> Anyhow, I thought that the first parameter was the number of file
> descriptors in the fd_set. It makes no sense to have to calculate what
> the highest numbered socket descriptor is before calling select ().
It's standard BSD select() use.
> On
> top of that, the example at the bottom of the documentation for select
> () is not very good. It passes a 1 in as the first parameter which is
> exactly why I thought it was the number of file descriptors and not the
> highest numbered one.
Ah, that's because it happens to choose stdin, which is always fd 0.
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine