libev,为什么在 evloop 中 recv 事件的编号是 3?

libev, why recv a event's number is 3 in evloop?

void callback(struct ev_loop *loop, ev_io *w, int events)
{
    if (EV_READ == events) {
      ...
    }
    else if (EV_WRITE == events) {
      ...
    }
    else {
      here recv event's number is 3
    }
}

在 libev 源代码 'ev.h' 中,我还没有找到定义数字 0x03 的宏

EV_READ     =            0x01, /* ev_io detected read will not block */
EV_WRITE    =            0x02, /* ev_io detected write will not block */

有点掩码。 3 表示可读和可写条件均可供处理。

试试

if (events & EV_READ) {  // something is readable
  ...
}
if (events & EV_WRITE) { // something is writable
  ...
}