#udp #server #frame #echo

udp_server

fast udp server frame

24 releases

0.4.1 Feb 2, 2021
0.4.0 Feb 1, 2021
0.3.6 Oct 30, 2020
0.3.5 Sep 24, 2020
0.1.4 Aug 20, 2020
Download history 73/week @ 2021-03-30 26/week @ 2021-04-06 67/week @ 2021-04-13 33/week @ 2021-04-20 2/week @ 2021-04-27 25/week @ 2021-05-04 1/week @ 2021-05-11 28/week @ 2021-05-18 1/week @ 2021-05-25 3/week @ 2021-06-01 28/week @ 2021-06-08 3/week @ 2021-06-15 2/week @ 2021-06-22 3/week @ 2021-06-29 4/week @ 2021-07-06 2/week @ 2021-07-13

120 downloads per month

MIT/Apache

16KB
285 lines

udp_server

fast rust udp server

Examples echo

#![feature(async_closure)]
use udp_server::UdpServer;
use std::error::Error;

#[tokio::main]
async fn main()->Result<(),Box<dyn Error>> {
    let mut a = UdpServer::<_,_,i32,_>::new("0.0.0.0:5555").await?;
    a.set_input(async move |_,peer,data|{
        peer.send(data).await?;
        Ok(())
    });

    a.start().await?;
    Ok(())
}

#if you need to use token

Examples token echo

#![feature(async_closure)]
use udp_server::UdpServer;
use std::error::Error;

#[tokio::main]
async fn main()->Result<(),Box<dyn Error>> {
    let mut a = UdpServer::new("0.0.0.0:5555").await?;
    a.set_input(async move |_,peer,data|{
        let mut token = peer.token.lock().await;
        match token.get() {
            Some(x)=>{
                *x+=1;
            },
            None=>{
                token.set(Some(1));
            }
        }
        peer.send(data).await?;
        Ok(())
    });

    a.start().await?;
    Ok(())
}

Dependencies

~3.5MB
~54K SLoC