#networking #uds #mio #reactor #std

async-net

Async networking primitives for TCP/UDP/Unix communication

16 stable releases

1.7.0 Aug 17, 2022
1.6.1 Jun 30, 2021
1.6.0 Apr 24, 2021
1.5.0 Oct 20, 2020
0.0.0 May 4, 2019

#24 in Network programming

Download history 26340/week @ 2023-02-15 27662/week @ 2023-02-22 26402/week @ 2023-03-01 25917/week @ 2023-03-08 24617/week @ 2023-03-15 27703/week @ 2023-03-22 26538/week @ 2023-03-29 22959/week @ 2023-04-05 25844/week @ 2023-04-12 24305/week @ 2023-04-19 28195/week @ 2023-04-26 22156/week @ 2023-05-03 24925/week @ 2023-05-10 22622/week @ 2023-05-17 24058/week @ 2023-05-24 21396/week @ 2023-05-31

96,873 downloads per month
Used in 279 crates (35 directly)

Apache-2.0 OR MIT

84KB
1K SLoC

async-net

Build License Cargo Documentation

Async networking primitives for TCP/UDP/Unix communication.

This crate is an async version of std::net and std::os::unix::net.

Implementation

This crate uses async-io for async I/O and blocking for DNS lookups.

Examples

A simple UDP server that echoes messages back to the sender:

use async_net::UdpSocket;

let socket = UdpSocket::bind("127.0.0.1:8080").await?;
let mut buf = vec![0u8; 1024];

loop {
    let (n, addr) = socket.recv_from(&mut buf).await?;
    socket.send_to(&buf[..n], &addr).await?;
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5–7.5MB
~128K SLoC