免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 13970 | 回复: 5
打印 上一主题 下一主题

[函数] 请问FD_SET,FD_ISSET这些函数是什么意思 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-04-29 14:55 |只看该作者 |倒序浏览
请问FD_SET,FD_ISSET这些函数是什么意思

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2003-04-29 15:08 |只看该作者

请问FD_SET,FD_ISSET这些函数是什么意思

FD_SET 打开类型fd_set的某一位
FD_ZERO初始化fd_set
FD_ISSET测试结构fd_set中的描述字

论坛徽章:
0
3 [报告]
发表于 2003-04-29 15:22 |只看该作者

请问FD_SET,FD_ISSET这些函数是什么意思

直接到vc98/include的文件中查找他们就可以找到代码。

论坛徽章:
0
4 [报告]
发表于 2003-04-29 15:23 |只看该作者

请问FD_SET,FD_ISSET这些函数是什么意思

fd_set有是什么东西

论坛徽章:
0
5 [报告]
发表于 2003-04-29 15:29 |只看该作者

请问FD_SET,FD_ISSET这些函数是什么意思


  1. #ifndef FD_SETSIZE
  2. #define FD_SETSIZE      64
  3. #endif /* FD_SETSIZE */

  4. typedef struct fd_set {
  5.         u_int fd_count;               /* how many are SET? */
  6.         SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
  7. } fd_set;

  8. extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *);

  9. #define FD_CLR(fd, set) do { \
  10.     u_int __i; \
  11.     for (__i = 0; __i < ((fd_set FAR *)(set))->;fd_count ; __i++) { \
  12.         if (((fd_set FAR *)(set))->;fd_array[__i] == fd) { \
  13.             while (__i < ((fd_set FAR *)(set))->;fd_count-1) { \
  14.                 ((fd_set FAR *)(set))->;fd_array[__i] = \
  15.                     ((fd_set FAR *)(set))->;fd_array[__i+1]; \
  16.                 __i++; \
  17.             } \
  18.             ((fd_set FAR *)(set))->;fd_count--; \
  19.             break; \
  20.         } \
  21.     } \
  22. } while(0)

  23. #define FD_SET(fd, set) do { \
  24.     u_int __i; \
  25.     for (__i = 0; __i < ((fd_set FAR *)(set))->;fd_count; __i++) { \
  26.         if (((fd_set FAR *)(set))->;fd_array[__i] == (fd)) { \
  27.             break; \
  28.         } \
  29.     } \
  30.     if (__i == ((fd_set FAR *)(set))->;fd_count) { \
  31.         if (((fd_set FAR *)(set))->;fd_count < FD_SETSIZE) { \
  32.             ((fd_set FAR *)(set))->;fd_array[__i] = (fd); \
  33.             ((fd_set FAR *)(set))->;fd_count++; \
  34.         } \
  35.     } \
  36. } while(0)

  37. #define FD_ZERO(set) (((fd_set FAR *)(set))->;fd_count=0)

  38. #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set))

复制代码

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
6 [报告]
发表于 2003-04-29 15:35 |只看该作者

请问FD_SET,FD_ISSET这些函数是什么意思

typedef int32_t __fd_mask;

#define _NFDBITS (sizeof(__fd_mask) *      /* 8 bits per byte */

#define __howmany(x,y)  (((x)+((y)-1))/(y))

#ifndef _FD_SET

#  define _FD_SET
   typedef struct __fd_set {
     long fds_bits[__howmany(FD_SETSIZE, (sizeof(long) * )];
     } fd_set;

#  ifndef _KERNEL
#    ifdef __cplusplus
        extern "C" {
#    endif /* __cplusplus */

#ifdef _INCLUDE_HPUX_SOURCE
#    define FD_SET(n,p)  (((__fd_mask *)((p)->;fds_bits))[(n)/_NFDBITS] |= (1 <<
((n) % _NFDBITS)))
#    define FD_CLR(n,p) (((__fd_mask *)((p)->;fds_bits))[(n)/_NFDBITS] &= ~(1 <<
((n) % _NFDBITS)))

#    define FD_ISSET(n,p) (((__fd_mask *)((p)->;fds_bits))[(n)/_NFDBITS] & (1 <<
((n) % _NFDBITS)))
#    define FD_ZERO(p)     memset((void *)(p), (int) 0, sizeof(*(p)))
#else
#    define FD_SET(n,p) (__fd_set1(n, p))
#    define FD_CLR(n,p) (__fd_clr(n, p))
#    define FD_ISSET(n,p) (__fd_isset(n, p))
#    define FD_ZERO(p)     memset((void *)(p), (int) 0, sizeof(fd_set))
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP