31 releases (5 stable)

1.0.4 Jan 18, 2024
1.0.3 Mar 6, 2023
1.0.2 Feb 27, 2023
0.5.1 Feb 21, 2023
0.3.6 Oct 30, 2020

#2085 in Network programming


Used in kcpserver

MIT/Apache

15KB
324 lines

udp_server

fast rust udp server

Latest Version Rust Documentation Rust Report Card Rust CI

Examples echo

use log::LevelFilter;
use udp_server::prelude::{IUdpPeer, UdpServer};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    env_logger::Builder::new()
        .filter_level(LevelFilter::Debug)
        .init();
    UdpServer::new("0.0.0.0:20001", |peer, mut reader, _| async move {
        while let Some(Ok(data)) = reader.recv().await {
            peer.send(&data).await?;
        }
        Ok(())
    })?
        .set_peer_timeout_sec(20)
        .start(())
        .await?;

    Ok(())
}

Dependencies

~4–10MB
~87K SLoC