#networking #uds #mio #reactor #std

async-net

Async networking primitives for TCP/UDP/Unix communication

17 releases (stable)

1.5.0 Oct 20, 2020
1.4.7 Oct 9, 2020
1.4.6 Sep 29, 2020
1.0.0 Aug 26, 2020
0.0.0 May 4, 2019

#72 in Network programming

Download history 6451/week @ 2020-12-25 9767/week @ 2021-01-01 9249/week @ 2021-01-08 7614/week @ 2021-01-15 8132/week @ 2021-01-22 7108/week @ 2021-01-29 6894/week @ 2021-02-05 7573/week @ 2021-02-12 7017/week @ 2021-02-19 6576/week @ 2021-02-26 6795/week @ 2021-03-05 7008/week @ 2021-03-12 6598/week @ 2021-03-19 7141/week @ 2021-03-26 8657/week @ 2021-04-02 8231/week @ 2021-04-09

32,390 downloads per month
Used in 116 crates (16 directly)

Apache-2.0 OR MIT

80KB
935 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
~19K SLoC