Chinaunix

标题: select函数在有句柄可以读写返回时,不直接返回是哪个句柄么? [打印本页]

作者: iw1210    时间: 2013-01-23 16:00
标题: select函数在有句柄可以读写返回时,不直接返回是哪个句柄么?
本帖最后由 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逐个判断集合内的句柄是否可读写?如果集合内有几十万个句柄,岂不是很慢了?
作者: lrita    时间: 2013-01-23 16:06
十几万个的话 还是用epoll/poll吧
作者: hellioncu    时间: 2013-01-23 16:17
LZ多虑了,就凭你现在这水平,能写出个支持几万个的就阿弥陀佛了
作者: iw1210    时间: 2013-01-23 16:23
hellioncu 发表于 2013-01-23 16:17
LZ多虑了,就凭你现在这水平,能写出个支持几万个的就阿弥陀佛了


是啊,请多指教啊~~~着急啊
作者: iw1210    时间: 2013-01-23 16:25
‘'that  is,  the  total  number  of  bits  that  are set in readfds, writefds, exceptfds"
什么意思?
作者: lrita    时间: 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时具体的数值对你来说没意义,用不上。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2