8

I think these are the two event-dealing libraries among the best.

These two both have many users,but which is better?

wireshark
  • 1,295
  • 2
  • 14
  • 20

2 Answers2

7

epoll is offered by Linux. libevent is built on top of epoll. Using epoll alone may thus be more efficient, if you know what you're doing.

blais
  • 687
  • 7
  • 9
  • Yep and [`libev`](http://cvs.schmorp.de/libev/ev_epoll.c?revision=1.68&view=markup&sortby=date) also uses `epoll()` has backend (when `epoll()` is available, else `libev` uses `poll()` or `select()`). – oHo May 07 '15 at 16:01
7

As mentioned by blais, libevent uses epoll internally. Libev (http://software.schmorp.de/pkg/libev.html) is also a good choice (I feel it is better than libevent, but that is just me). As for me, I've used epoll directly in some projects and libev in other projects. I like libev because it also provides timers, signals, periodic timers (cron-like), and stat watchers.

So, which is better? If you want to watch a few socket descriptors then epoll is probably all you need. If you are writing a multi-threaded application then libevent/libev would probably be a better way to go. I don't think you'll see an appreciable speed difference between epoll and libevent/libev.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
j.w.r
  • 4,136
  • 2
  • 27
  • 29
  • 3
    According to this, libev is a bit faster than libevent. http://libev.schmorp.de/bench.html – hookenz Dec 05 '11 at 01:33
  • 1
    Probably should have stated that choosing between epoll and libev has also to do with the platform one is targetting -- epoll is only available in Linux kernel, not on BSD or anything else. – Armen Michaeli Apr 09 '16 at 20:09