Build a high-performance TCP server in Rust that handles many simultaneous connections without blocking.
Write a custom async networking library on top of Mio's event loop, allocating nothing at runtime after setup.
Port async networking code across Linux, macOS, Windows, Android, and iOS using Mio's unified cross-platform API.
Requires solid Rust knowledge, beginners should use Tokio instead as Mio is a low-level building block not intended for direct use.
Mio is a low-level Rust library for handling network connections without blocking. In most programs, when you read from a network socket, the program pauses and waits until data arrives. Non-blocking I/O means the program does not wait: instead, it asks the operating system to notify it when a socket is ready to read or write, and can do other work in between. Mio provides a thin, efficient layer over those operating system notifications. The library wraps the native event systems built into each major operating system. On Linux that is epoll, on macOS and BSD systems it is kqueue, and on Windows it is IOCP. Mio presents a consistent API across all of them, so code written with Mio works on Linux, macOS, Windows, Android, iOS, and several BSD variants without changes. The core concept is a Poll object, which you create once, then register sockets with it. Each socket gets a token, which is just a number you choose. You call poll repeatedly in a loop, and each time it returns a list of events. Each event includes the token of the socket that triggered it, and whether the socket is ready to read, write, or both. You then handle those events in whatever way your program needs. Mio explicitly does not include file operations, thread pools, or timers. Those are intentionally left out to keep the library focused and to avoid overhead that not every program needs. Higher-level libraries, such as Tokio, are built on top of Mio and add those features. The README notes that if you are new to async Rust networking, Tokio is likely a better starting point than using Mio directly. Mio is designed to allocate nothing at runtime after initial setup, which matters for programs handling large numbers of simultaneous connections where memory allocation overhead can become significant. It is used as a building block by several important Rust async runtimes and networking libraries.
← tokio-rs on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.