libev,为什么在evloop中收到一个事件的数字是3?

时间:2017-08-07 04:36:20

标签: c++ c linux networking libev

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 */

1 个答案:

答案 0 :(得分:2)

它有点面具。 3表示可以处理可读和可写条件。

尝试类似

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