Crates.io | udp_server |
lib.rs | udp_server |
version | 1.0.4 |
source | src |
created_at | 2020-08-19 01:49:49.583945 |
updated_at | 2024-01-18 07:30:12.841555 |
description | fast udp server frame. |
homepage | |
repository | https://github.com/luyikk/udp_server |
max_upload_size | |
id | 278081 |
size | 45,864 |
fast rust udp server
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(())
}