【问题标题】:Is there a kqueue()/kevent() equivalent to select()'s "errorfds" set?是否有等效于 select() 的“errorfds”集的 kqueue()/kevent()?
【发布时间】:2012-01-01 03:35:59
【问题描述】:

我今天将一些代码从 select() 移植到 kqueue(),我注意到 kevent() 似乎没有 select() 的“异常集”功能的模拟。

也就是说select()的function-signature是:

int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict errorfds, struct timeval *restrict timeout);

...对于 kevent(),EVFILT_READ 对应于 (readfds),而 EVFILT_WRITE 对应于 (writefds),但我没有看到任何类似 EVFILT_ERROR 的东西对应于 (errorfds)。

真的只是不支持 kevent() 下的套接字错误条件,还是存在但以某种对我来说并不明显的方式实现?

【问题讨论】:

  • 你需要什么errorfds?读取错误已通过读取事件报告,写入错误通过写入事件报告(通过导致读取或写入失败)。

标签: select error-handling kqueue


【解决方案1】:

无法以这种方式进行过滤。您必须根据标志 (EV_EOF) 和 fflags 手动对传入事件进行分类。

【讨论】:

    猜你喜欢
    • 2010-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    相关资源
    最近更新 更多