Re: question on select & FD_ISSET
Junior <firstname.lastname@example.org> wrote:
> Hi all,
> When I do an FD_ISSET, does it clear that fd bit in the set or it leaves =
> it as it is (set or not)?
> If it leaves it then I'll have to do an FD_CLR and an FD_SET the next time =
> around, correct? (if it is set)
> It would seem the FD_ISSET would/should take care of this, no?
The fdsets that you pass in to select are modified by select so that only
the fds that need attention are set. FD_ISSET only tests the specified
fd, it does not modify the fdset.
The usual way to use select is in a loop. At the top you set all the
fds in your fdsets, call select, the check which ones are still set
using FD_ISSET(), then go back up to the top.
See the select_tut(2) man page for examples.
See W. Richard Stevens' "Advanced Programming in the Unix Environment"
for a detailed description of what's happening.
The universal acid of the true knowledge had burned away a world of words,
and exposed a universe of things. Things we could use. -- Ken MacLeod