简体   繁体   English

libev,为什么在evloop中接收事件的编号为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
    }
}

In libev source code 'ev.h', i had not been find macro to define number 0x03 在libev源代码“ ev.h”中,我没有找到定义数字0x03的宏

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

It's a bit mask. 这是一个面具。 3 indicates both a readable and writable condition are available to process. 3表示可读条件和可写条件均可供处理。

Try something like 尝试类似

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM