免费注册 查看新帖 |

Chinaunix

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

select里timeout设为0,立即返回的话,select的返回值是什么? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-26 13:18 |只看该作者 |倒序浏览
如果可以操作了,返回什么?如果在不可以操作的情况下立即返回这时的select返回值是什么?

论坛徽章:
0
2 [报告]
发表于 2008-11-26 13:39 |只看该作者

  1. RETURN VALUES

  2.   Upon successful completion, the select() function returns the number of
  3.   ready objects represented by corresponding file descriptor bits in the I/O
  4.   descriptor sets. When an error occurs, -1 is returned and errno is set to
  5.   indicate the error.

  6.   If the time limit expires before any event occurs that would cause one of
  7.   the masks to be set to a non-zero value, select() completes successfully
  8.   and returns 0 (zero).

  9.   When select() returns an error, including a process interrupt, the I/O
  10.   descriptor sets pointed to by the readfds, writefds, and exceptfds parame-
  11.   ters remain unmodified.
复制代码

论坛徽章:
0
3 [报告]
发表于 2008-11-26 21:13 |只看该作者
这段话看过,还是不知道。。
timeout设为零是立即返回,
那么如果可以操作的话,应该是可操作描述符数目
但是不可操作的话,是做超时处理返回0呢,还是做出错处理返回-1?

论坛徽章:
0
4 [报告]
发表于 2008-11-26 21:39 |只看该作者
原帖由 john.daker 于 2008-11-26 21:13 发表
这段话看过,还是不知道。。
timeout设为零是立即返回,
那么如果可以操作的话,应该是可操作描述符数目
但是不可操作的话,是做超时处理返回0呢,还是做出错处理返回-1?

当然是返回0

论坛徽章:
0
5 [报告]
发表于 2008-11-26 21:59 |只看该作者
返回0。表示successfully
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP