Standard library / std::net

std::net

This is the canonical module doc for std::net.

std::net provides the hosted networking API shipped in std/net.slk: byte-order helpers, IPv4/IPv6 address types, TCP and UDP sockets, hostname resolution, and the current async socket integration layer.

TCP writes on Linux and macOS suppress SIGPIPE per send. If the socket reports EPIPE, TCPStream.write, write_all, and write_string return NetErrorKind::BrokenPipe instead of terminating the process. Other socket errors retain their normal mapping; process-wide signal handlers are unchanged.

On Apple targets using the auto or platform security provider, builds that import std::net link Network.framework as the platform networking provider surface is brought online. The current public API remains the hosted socket API documented in networking.

The detailed API contract and platform/runtime notes are documented in:

Read that page as the complete public surface for:

  • byte-order helpers such as htons, ntohs, htonl, ntohl
  • Ipv4Addr and Ipv6Addr
  • SocketAddrV4, SocketAddrV6, and SocketAddr
  • NetErrorKind, NetFailed, and the Net*Result aliases
  • ResolveIpMode and resolve_host(...)
  • deadline-aware resolve_host_timeout(...) and TCPStream.connect_timeout(...)
  • TCPStream, TCPListener, UDPv4Socket, and UDPv6Socket
  • current async connect / accept support

Related docs:

Source repository · Edit this page · View Markdown

Quick links

Type to search across the site. Use the up and down arrow keys to choose a result, Enter to open it, and Escape to close.