poll函数的第三个参数timeout
第三个参数 我想定义无限等待
于是我把它设置成 INFTIM
但是编译时出错,说未定义该常量
这两个头文件写了 #include <poll.h> 和 #include <sys/stropts.h>都写了
怎么会这样的?知道的人告诉我一下,谢谢!!!
[解决办法]
这个就是-1,的确没有这个宏。
[解决办法]
INFTIM:
BSD 定义在 <poll.h>
SYSV 定义在 <stropts.h>
实在没有自己定义一下就可以了,或者直接用-1
应为POSIX标准里并没有 INFTIM, 而是用-1
If the value of timeout is -1, poll() shall block until a requested event occurs or until the call is interrupted.
所以建议直接使用-1,容易适应不同的系统。
[解决办法]
[解决办法]
The timeout argument specifies an upper limit on the time for which poll() will block, in milliseconds. Specifying a negative value
in timeout means an infinite timeout.
负数都行。