typedef unsigned int u_int;
typedef u_int SOCKET;
typedef struct fd_set {
u_int fd_count;
SOCKET fd_array[FD_SETSIZE];
} fd_set;
#define FD_CLR(fd, set) \
do \
{ \
u_int __i; \
for (__i = 0; __i < ((fd_set *)(set))->fd_count; __i++) \
{ \
if (((fd_set *)(set))->fd_array[__i] == (fd)) \
{ \
while (__i < ((fd_set *)(set))->fd_count - 1) \
{ \
((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i + 1]; \
__i++; \
} \
((fd_set*)(set))->fd_count--; \
break; \
} \
} \
} while (0)
#define FD_SET(fd, set) \
do \
{ \
u_int __i; \
for (__i = 0; __i < ((fd_set *)(set))->fd_count; __i++) \
{ \
if (((fd_set *)(set))->fd_array[__i] == (fd)) \
{ \
break; \
} \
} \
if (__i == ((fd_set *)(set))->fd_count) \
{ \
if (((fd_set *)(set))->fd_count < FD_SETSIZE) \
{ \
((fd_set *)(set))->fd_array[__i] = (fd); \
((fd_set *)(set))->fd_count++; \
} \
} \
} while(0)
#define FD_ZERO(set) (((fd_set *)(set))->fd_count = 0)
#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
No comments:
Post a Comment