Using kqueue to poll for exceptional conditions

463 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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.