简体   繁体   中英

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

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.

Try something like

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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