Expand description
§tokio-raknet
A high-performance, asynchronous implementation of the RakNet protocol written in pure Rust. Built on top of the Tokio runtime, it is designed to provide a modern, ergonomic API for building robust UDP-based networked applications, games, and services.
§Features
- Fully Asynchronous: Built with
async/awaitfor high concurrency. - Reliability Layers: Support for Reliable, Unreliable, Ordered, Sequenced, etc.
- Fragmentation: Automatic splitting and reassembly of large packets.
- Simple API: High-level abstraction resembling
TcpStreambut for UDP/RakNet.
§Example: Client
use tokio_raknet::RaknetStream;
use bytes::Bytes;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = RaknetStream::connect("127.0.0.1:19132".parse()?).await?;
client.send("Hello!").await?;
Ok(())
}§Example: Server
use tokio_raknet::RaknetListener;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut listener = RaknetListener::bind("0.0.0.0:19132".parse()?).await?;
while let Some(mut conn) = listener.accept().await {
tokio::spawn(async move {
while let Some(msg) = conn.recv().await {
// Handle packet
}
});
}
Ok(())
}Re-exports§
pub use error::RaknetError;pub use transport::RaknetListener;pub use transport::RaknetStream;
Modules§
- error
- tokio-raknet
- protocol
- RakNet protocol primitives, control packets, and related state.
- session
- RakNet per-peer session state and reliability/ordering logic. Keeps the Session struct and shared helpers; per-area logic lives in submodules (outbound, inbound, tick).
- transport
- Tokio-based UDP transport layer for RakNet sessions.