|
Home > Archive > Unix Programming > June 2007 > select and fd_isset
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
select and fd_isset
|
|
| 02B12S 2007-06-24, 1:27 pm |
| I have a select which can return multiple descriptor (read, write,
exception). I know the # of descriptors ready for processing from the
select call return value.
Is their a way to test the "fd_set" read/write/except values to determine
if "Any" of the returned file descriptors are in their respective values. I
hate to loop through and test each bit using fd_isset, if nothing is set in
that group.
What I'd like to do,
if select returns the # of descriptors set ,
test each fd_set read/write/except for non-zero,
then loop through using fd_isset only the descriptors that have bits set.
This was easy when I used plain int bitmasks for select. but trying to do
this using fd_ macro's seem to force the use of a loop.
JJ
| |
| Rainer Weikusat 2007-06-24, 1:27 pm |
| "02B12S" <johndelimiterjemiolo@atmindspring.com> writes:
> I have a select which can return multiple descriptor (read, write,
> exception). I know the # of descriptors ready for processing from the
> select call return value.
>
> Is their a way to test the "fd_set" read/write/except values to determine
> if "Any" of the returned file descriptors are in their respective values. I
> hate to loop through and test each bit using fd_isset, if nothing is set in
> that group.
A possible solution would be to keep a zeroed fd_set around and to use
memcmp to determine if one of the returned sets has a value different
from it.
| |
| Barry Margolin 2007-06-25, 1:22 am |
| In article <eptfi.355$Od7.19@newsread1.news.pas.earthlink.net>,
"02B12S" <johndelimiterjemiolo@atmindspring.com> wrote:
> I have a select which can return multiple descriptor (read, write,
> exception). I know the # of descriptors ready for processing from the
> select call return value.
>
> Is their a way to test the "fd_set" read/write/except values to determine
> if "Any" of the returned file descriptors are in their respective values. I
> hate to loop through and test each bit using fd_isset, if nothing is set in
> that group.
If you have so many descriptors in your set that this is a performance
problem, maybe poll() would be a better API than select() for your
application.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
|
|
|
|