Chinaunix

标题: select里timeout设为0,立即返回的话,select的返回值是什么? [打印本页]

作者: john.daker    时间: 2008-11-26 13:18
标题: select里timeout设为0,立即返回的话,select的返回值是什么?
如果可以操作了,返回什么?如果在不可以操作的情况下立即返回这时的select返回值是什么?
作者: gawk    时间: 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.
复制代码

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

当然是返回0
作者: nicozhou    时间: 2008-11-26 21:59
返回0。表示successfully




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