1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
//! Networking primitives for TCP/UDP communication. //! //! For OS-specific networking primitives like Unix domain sockets, refer to the [`async_std::os`] //! module. //! //! This module is an async version of [`std::net`]. //! //! [`async_std::os`]: ../os/index.html //! [`std::net`]: https://doc.rust-lang.org/std/net/index.html //! //! ## Examples //! //! A simple UDP echo server: //! //! ```no_run //! # fn main() -> std::io::Result<()> { async_std::task::block_on(async { //! # //! use async_std::net::UdpSocket; //! //! let socket = UdpSocket::bind("127.0.0.1:8080").await?; //! let mut buf = vec![0u8; 1024]; //! //! loop { //! let (n, peer) = socket.recv_from(&mut buf).await?; //! socket.send_to(&buf[..n], &peer).await?; //! } //! # //! # }) } //! ``` pub use std::net::AddrParseError; pub use std::net::Shutdown; pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; pub use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; pub use addr::ToSocketAddrs; pub use tcp::{Incoming, TcpListener, TcpStream}; pub use udp::UdpSocket; mod addr; pub(crate) mod driver; mod tcp; mod udp;