libevent runs callbacks on file descriptors, timeouts, and signals for event-driven network servers. It wraps epoll, kqueue, poll, and other OS mechanisms behind one dispatch API.
Overview
libevent is an event notification library for C programs that need non-blocking I/O and timers. Applications register events and call event dispatch so the loop can wake on socket readiness, timeouts, or signals without rewriting the loop for each platform.
It supports several kernel interfaces—including epoll, kqueue, /dev/poll, poll, and POSIX or Windows select—and keeps the public API separate from the backend so ports can gain new mechanisms with library updates. The design targets portable, scalable server development and multi-threaded use either with per-thread event bases or locked shared bases.
Beyond the core loop, libevent includes buffered network I/O (bufferevents) with sockets, filters, rate limiting, SSL, zero-copy sendfile-style paths, and Windows IOCP. Higher-level modules cover DNS, HTTP, and a minimal RPC framework. Documentation spans a manual, a Programming with Libevent book, and versioned API references.
The authors report builds on Linux, BSD, macOS, Solaris, Windows, and other platforms. Stable and alpha release tarballs are distributed from the project site; vcpkg also packages libevent on Windows-oriented workflows.
Key features
- Unified event dispatch API
- epoll, kqueue, poll, select backends
- Timeout and signal callbacks
- Buffered network I/O layer
- Built-in HTTP and DNS support
- SSL and rate-limited bufferevents
- Multi-threaded event base patterns
- Portable C server development
Use cases
- Event-driven TCP servers
- Non-blocking network clients
- Timer-driven daemons
- HTTP services on libevent
- Replacing hand-rolled select loops