免费注册 查看新帖 |

Chinaunix

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

[C] select函数在有句柄可以读写返回时,不直接返回是哪个句柄么? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-01-23 16:00 |只看该作者 |倒序浏览
本帖最后由 iw1210 于 2013-01-23 16:05 编辑

select函数在有句柄可以读写返回时,不直接返回是哪个句柄么? 看介绍好像不是返回那个句柄啊:

RETURN VALUE
       On  success,  select() and pselect() return the number of file descrip-
       tors contained in the three returned  descriptor  sets  (that  is,  the
       total  number  of  bits  that  are set in readfds, writefds, exceptfds)
       which may be zero if the timeout expires  before  anything  interesting
       happens.  On error, -1 is returned, and errno is set appropriately; the
       sets and timeout become undefined, so do not  rely  on  their  contents
       after an error.

这里说的如果成功返回什么?没翻译明白~


难道必须用FD_ISSET逐个判断集合内的句柄是否可读写?如果集合内有几十万个句柄,岂不是很慢了?

论坛徽章:
0
2 [报告]
发表于 2013-01-23 16:06 |只看该作者
十几万个的话 还是用epoll/poll吧

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
3 [报告]
发表于 2013-01-23 16:17 |只看该作者
LZ多虑了,就凭你现在这水平,能写出个支持几万个的就阿弥陀佛了

论坛徽章:
0
4 [报告]
发表于 2013-01-23 16:23 |只看该作者
hellioncu 发表于 2013-01-23 16:17
LZ多虑了,就凭你现在这水平,能写出个支持几万个的就阿弥陀佛了


是啊,请多指教啊~~~着急啊

论坛徽章:
0
5 [报告]
发表于 2013-01-23 16:25 |只看该作者
‘'that  is,  the  total  number  of  bits  that  are set in readfds, writefds, exceptfds"
什么意思?

论坛徽章:
0
6 [报告]
发表于 2013-01-23 16:56 |只看该作者
iw1210 发表于 2013-01-23 16:25
‘'that  is,  the  total  number  of  bits  that  are set in readfds, writefds, exceptfds"
什么意思 ...

用的时候只需要判断返回值 -1,0,>0的情况,>0时具体的数值对你来说没意义,用不上。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP