Anyone ever use the select() function?

engineereeyore

Platinum Member
Jul 23, 2005
2,070
0
0
Ok, I understand how to add file descriptors and the whole idea of what select does. I understand that it returns the number of descriptors that are ready to be read, write, or handled. What I don't understand is how I'm supposed to know WHICH desciptor is ready. Does it reorganize the fd_set array so that all the ones that are ready are at the front of the array, or do I have to go through all of them and check them somehow?

Any help would be greatly appreciated.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I believe you use the FD_ISSET macro to determine if a certain descriptor is in the 'ready' category. If you have a Linux box handy there's a select_tut(2) man page in the manpages-dev (on Debian at least) package which might answer your question.
 

engineereeyore

Platinum Member
Jul 23, 2005
2,070
0
0
You would appear to be correct. I was hoping it was more specific, but I guess that's still much better than performing a read on several different socket descriptors.

Thanks for the info. That man page is very nice.