使用 kqueue 轮询异常情况

发布于 2024-08-10 18:29:10 字数 465 浏览 2 评论 0原文

我正在修改一个应用程序,以便将其对 select() 的使用替换为 kqueue。 select() 允许轮询异常条件:

int select(int nfds,
     fd_set *restrict readfds,
     fd_set *restrict writefds,
     fd_set *restrict errorfds,           <---- this thing here
     struct timeval *restrict timeout
);

阅读 kqueue 文档后,似乎没有办法做到这一点。有 EVFILT_READEVFILT_WRITE,但没有与 EVFILT_ERROR/EVFILT_EXCEPTIONAL 类似的内容。是否可以轮询特殊情况?如果可以,如何进行?

I'm modifying an app in order to replace its use of select() with kqueue. select() allows one to poll for exceptional conditions:

int select(int nfds,
     fd_set *restrict readfds,
     fd_set *restrict writefds,
     fd_set *restrict errorfds,           <---- this thing here
     struct timeval *restrict timeout
);

After reading the kqueue documentation it looks like there's no way to do that. There's EVFILT_READ and EVFILT_WRITE but nothing along the lines of EVFILT_ERROR/EVFILT_EXCEPTIONAL. Is it possible to poll for exceptional conditions, and if so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻梦 2024-08-17 18:29:10

FreeBSD 上不存在异常状态,引用 man 2 select

唯一可检测的异常情况是套接字上接收到的带外数据。

所以你的问题归结为“如何使用 kqueue 检测套接字上的 OOB 数据”,老实说,如果不做一些研究,我无法回答这个问题。

There is no such thing as exceptional state on FreeBSD, to quote man 2 select:

The only exceptional condition detectable is out-of-band data received on a socket.

So your question boils down to “How can I detect OOB-data on a socket with kqueue”, which I, to be honest, cannot answer without doing some research.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文