#networking #uds #mio #reactor #std

async-net

Async networking primitives for TCP/UDP/Unix communication

19 releases (stable)

1.6.1 Jun 30, 2021
1.6.0 Apr 24, 2021
1.5.0 Oct 20, 2020
1.4.6 Sep 29, 2020
0.0.0 May 4, 2019

#101 in Network programming

Download history 9241/week @ 2021-05-31 9360/week @ 2021-06-07 10212/week @ 2021-06-14 10340/week @ 2021-06-21 10599/week @ 2021-06-28 9683/week @ 2021-07-05 10280/week @ 2021-07-12 12259/week @ 2021-07-19 11239/week @ 2021-07-26 10700/week @ 2021-08-02 10668/week @ 2021-08-09 10899/week @ 2021-08-16 12520/week @ 2021-08-23 12130/week @ 2021-08-30 14244/week @ 2021-09-06 13357/week @ 2021-09-13

41,192 downloads per month
Used in 156 crates (25 directly)

Apache-2.0 OR MIT

79KB
929 lines

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

~1MB
~18K SLoC