????????????????д??????????????????????漰??IO???????????????????????select??????????????????????????????????????????????Linux???£?????windows???£?select??????????????????????????????????select?????????????????????????????
??????windows???浥??fd_set???????socket handle???????????FD_SETSIZE(??win32 winsock2.h???????64????VS2010?汾??)??????fd_set????????????????????Щsocket handle??????FD_SET??????????????з??????socket handle?????????????????????????FD_SETSIZE?????????????winsock2.h??FD_SET?????塣
???????????????
?????????fd_set?е?socket handle?????FD_SETSIZE?????????????FD_SET??????????????Ч????????socket handle??IO????????????????
????????Linux?????棬???????????????fd_set?????FD_SET????????fd_set???????bitλ??????????????????IO?????fd?????????????????????
????/usr/include/sys/select.h??
1 typedef long int __fd_mask;
2 #define __NFDBITS    (8 * sizeof (__fd_mask))
3 #define    __FDELT(d)    ((d) / __NFDBITS)
4
5 #define    __FDMASK(d)    ((__fd_mask) 1 << ((d) % __NFDBITS))
6
7 typedef struct
8   {
9     /* XPG4.2 requires this member name.  Otherwise avoid the name
10        from the global namespace.  */
11 #ifdef __USE_XOPEN
12     __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
13 # define __FDS_BITS(set) ((set)->fds_bits)
14 #else
15     __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
16 # define __FDS_BITS(set) ((set)->__fds_bits)
17 #endif
18   } fd_set;
19
20 #define    FD_SET(fd?? fdsetp)    __FD_SET (fd?? fdsetp)
????/usr/include/bits/select.h??
????1 # define __FD_SET(d?? set)    (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
????????????????????????????????bit??fd_set??bit?????е?λ??????fd???????fd_set????bitλ??????__FD_SETSIZE??????__FD_SETSIZE??/usr/include/bits/typesize.h(???????????sys/socket.h -> bits/types.h -> bits/typesizes.h)?б??????1024??
??????????????????fd>=1024???FD_SET???????????????д??硣?????????man select?ж????????????????????
????NOTES
????An fd_set is a fixed size buffer. Executing FD_CLR() or FD_SET() with a value of fd that is negative or is equal to or
????larger than FD_SETSIZE will result in undefined behavior. Moreover?? POSIX requires fd to be a valid file descriptor.
??????????????????????????????????????????????????????? select ????????????????????????
?????????????Linux??select????????????????????С??????????fd????1024????????????????????????????????poll??epoll?ɡ?
?????????е?????????????????????????????????Linux????fd??????????????????????fd??int??????????????????????????????????????????????????????2.6.30?汾??kernel?????????????