You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
John Nunley 0f38ed35ea
Add edge/oneshot combination mode (#96)
6 days ago
.github ci: Fix Android breakage (#99) 1 week ago
examples feat: Expose other kqueue filters (#83) 2 months ago
src Add edge/oneshot combination mode (#96) 6 days ago
tests Add edge/oneshot combination mode (#96) 6 days ago
.cirrus.yml Test more Windows targets on CI 4 weeks ago
.gitignore Version 2.6.0 (#92) 3 weeks ago
Cargo.toml Version 2.6.0 (#92) 3 weeks ago
Cross.toml ci: Fix Android breakage (#99) 1 week ago
LICENSE-MIT m(windows): Reimplement Wepoll in Rust (#88) 4 weeks ago


Build License Cargo Documentation

Portable interface to epoll, kqueue, event ports, and IOCP.

Supported platforms:

  • epoll: Linux, Android
  • kqueue: macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD
  • event ports: illumos, Solaris
  • poll: VxWorks, Fuchsia, other Unix systems
  • IOCP: Windows, Wine (version 7.13+)

Polling is done in oneshot mode, which means interest in I/O events needs to be reset after an event is delivered if we're interested in the next event of the same kind.

Only one thread can be waiting for I/O events at a time.


use polling::{Event, Poller};
use std::net::TcpListener;

// Create a TCP listener.
let socket = TcpListener::bind("")?;
let key = 7; // Arbitrary key identifying the socket.

// Create a poller and register interest in readability on the socket.
let poller = Poller::new()?;
poller.add(&socket, Event::readable(key))?;

// The event loop.
let mut events = Vec::new();
loop {
    // Wait for at least one I/O event.
    poller.wait(&mut events, None)?;

    for ev in &events {
        if ev.key == key {
            // Perform a non-blocking accept operation.
            // Set interest in the next readability event.
            poller.modify(&socket, Event::readable(key))?;


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.