docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

std::net

本頁內容

API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。

TCP / UDP sockets, addresses, DNS. Unix sockets are os::unix::net, the Linux kernel copies os::linux::net::TcpStreamExt.

Three layers: Socket (domain, type, protocol and options, each call one system call), the typed TcpStream::connect / TcpListener::bind / UdpSocket::bind over ToSocketAddrs, and the free tcp_connect / tcp_listen / udp_bind beside them.

Sockets are non-blocking underneath. Blocking calls wait in poll, so set_*_timeout bounds that wait (async uses task::timeout), and set_nonblocking(true) makes them throw WouldBlock. *_async calls suspend until the I/O driver sees the fd ready.

A plain call never suspends: inside a task it blocks the worker, because a sync fn cannot suspend a stackless coroutine.

read(buf) fills buf[0..n] of a SliceMut<u8>; writes take any AsBytes. No IPv6 multicast. TLS 1.3 is tls.

Modules

  • tls TLS 1.3, implemented here in Nabi on core::crypto: no OS or external TLS library.

Structs

Ipv4AddrSource

pub struct Ipv4Addr

An IPv4 address.

  • pub const LOCALHOST: Ipv4Addr = Ipv4Addr { octets: [127u8, 0u8, 0u8, 1u8] }§

    Source

    The loopback address.

  • pub const UNSPECIFIED: Ipv4Addr = Ipv4Addr { octets: [0u8, 0u8, 0u8, 0u8] }§

    Source

    The unspecified (any) address.

  • pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr§

    Source

    The address a.b.c.d.

  • pub const fn octets(self) -> [u8; 4]§

    Source

    The four bytes, most significant first.

  • pub const fn to_bits(self) -> u32§

    Source

    The address as a big-endian number (a.b.c.d = a << 24 | ..).

  • pub const fn is_loopback(self) -> bool§

    Source

    true for 127.0.0.0/8.

  • pub const fn is_unspecified(self) -> bool§

    Source

    true for 0.0.0.0.

  • pub const fn is_multicast(self) -> bool§

    Source

    true for 224.0.0.0/4.

Trait implementations 4

Ipv6AddrSource

pub struct Ipv6Addr

An IPv6 address.

  • pub const LOCALHOST: Ipv6Addr = Ipv6Addr { segments: [0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 1u16] }§

    Source

    The loopback address.

  • pub const UNSPECIFIED: Ipv6Addr = Ipv6Addr { segments: [0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16, 0u16] }§

    Source

    The unspecified (any) address.

  • pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr§

    Source

    The address a:b:c:d:e:f:g:h, one 16-bit segment each.

  • pub const fn segments(self) -> [u16; 8]§

    Source

    The eight 16-bit groups, most significant first.

  • pub const fn is_loopback(self) -> bool§

    Source

    true for ::1.

Trait implementations 3

SocketAddrV4Source

pub struct SocketAddrV4

An IPv4 address and a port.

  • pub const fn new(ip: Ipv4Addr, port: u16) -> SocketAddrV4§

    Source

    ip:port.

  • pub const fn ip(self) -> Ipv4Addr§

    Source

    The IP address.

  • pub const fn port(self) -> u16§

    Source

    The port.

  • pub const fn set_ip(ref self, ip: Ipv4Addr)§

    Source

    Replace the IP address.

  • pub const fn set_port(ref self, port: u16)§

    Source

    Replace the port.

Trait implementations 3

SocketAddrV6Source

pub struct SocketAddrV6

An IPv6 address, a port, the flow label and the scope (interface) id.

  • pub const fn new(ip: Ipv6Addr, port: u16, flow_info: u32 = 0u32, scope_id: u32 = 0u32) -> SocketAddrV6§

    Source

    [ip]:port, with an optional flow label and scope id.

  • pub const fn ip(self) -> Ipv6Addr§

    Source

    The IP address.

  • pub const fn port(self) -> u16§

    Source

    The port.

  • pub const fn flow_info(self) -> u32§

    Source

    The flow label (sin6_flowinfo).

  • pub const fn scope_id(self) -> u32§

    Source

    The scope id (sin6_scope_id), an interface index.

  • pub const fn set_ip(ref self, ip: Ipv6Addr)§

    Source

    Replace the IP address.

  • pub const fn set_port(ref self, port: u16)§

    Source

    Replace the port.

  • pub const fn set_flow_info(ref self, flow_info: u32)§

    Source

    Replace the flow label.

  • pub const fn set_scope_id(ref self, scope_id: u32)§

    Source

    Replace the scope id.

Trait implementations 3

ProtocolSource

pub struct Protocol

An IP protocol number (the IANA registry).

  • pub const ICMPV4: Protocol = Protocol { number: 1 }§

    Source

    ICMP for IPv4.

  • pub const TCP: Protocol = Protocol { number: 6 }§

    Source

    TCP.

  • pub const UDP: Protocol = Protocol { number: 17 }§

    Source

    UDP.

  • pub const ICMPV6: Protocol = Protocol { number: 58 }§

    Source

    ICMP for IPv6.

  • pub const fn new(number: i32) -> Protocol§

    Source

    The protocol numbered number (IANA).

  • pub const fn number(self) -> i32§

    Source

    The IANA protocol number.

SocketSource

pub struct Socket

A socket as the OS has it: any domain, type and protocol, its options, and each call one system call (bind does not set SO_REUSEADDR, connect does not resolve). TcpStream::from(s), TcpListener::from(s) and UdpSocket::from(s) take it over once it is set up, and Socket::from goes back. It has one owner: let b = a moves it.

  • pub fn new(domain: Domain, ty: SocketType, protocol: Protocol | none = none) throws (IoError) -> Socket§

    Source

    A new socket (non-blocking underneath, not inherited by child processes); protocol none is the default for ty.

  • pub fn bind(self, addr: SocketAddr) throws (IoError)§

    Source

    Bind to addr.

  • pub fn listen(self, backlog: i32) throws (IoError)§

    Source

    Listen for connections, queueing at most backlog pending ones.

  • pub fn connect(self, addr: SocketAddr) throws (IoError)§

    Source

    Connect, blocking until the handshake is done (in non-blocking mode, WouldBlock while it is in progress).

  • pub fn connect_timeout(self, addr: SocketAddr, dur: Duration) throws (IoError)§

    Source

    connect that throws TimedOut after dur.

  • pub async fn connect_async(ref self, addr: SocketAddr) throws (IoError)§

    Source

    connect that suspends the task during the handshake.

  • pub fn accept(self) throws (IoError) -> (Socket, SocketAddr)§

    Source

    The next connection and its peer, blocking until one arrives.

  • pub async fn accept_async(ref self) throws (IoError) -> (Socket, SocketAddr)§

    Source

    accept that suspends the task until a connection arrives.

  • pub fn local_addr(self) throws (IoError) -> SocketAddr§

    Source

    The address this socket is bound to.

  • pub fn peer_addr(self) throws (IoError) -> SocketAddr§

    Source

    The address of the connected peer.

  • pub fn shutdown(self, how: Shutdown) throws (IoError)§

    Source

    Shut down reading, writing or both.

  • pub async fn shutdown_async(ref self, how: Shutdown) throws (IoError)§

    Source

    As shutdown, which never waits.

  • pub fn send_to<B: AsBytes>(self, buf: B, addr: SocketAddr) throws (IoError) -> usize§

    Source

    Send the datagram buf to addr; bytes sent.

  • pub async fn send_to_async<B: AsBytes>(ref self, buf: B, addr: SocketAddr) throws (IoError) -> usize§

    Source

    send_to that suspends the task while the socket is full.

  • pub fn recv_from(self, buf: SliceMut<u8>) throws (IoError) -> (usize, SocketAddr)§

    Source

    The next datagram into buf[0..n] (truncated to buf.len()) and its sender.

  • pub async fn recv_from_async(ref self, buf: SliceMut<u8>) throws (IoError) -> (usize, SocketAddr)§

    Source

    recv_from that suspends the task until a datagram arrives.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make the blocking calls throw WouldBlock instead of waiting.

  • pub const fn set_read_timeout(self, dur: Duration | none)§

    Source

    Limit blocking reads to dur, then TimedOut; none waits forever.

  • pub const fn set_write_timeout(self, dur: Duration | none)§

    Source

    Limit blocking writes to dur, then TimedOut; none waits forever.

  • pub const fn read_timeout(self) -> Duration | none§

    Source

    The read timeout; none for none.

  • pub const fn write_timeout(self) -> Duration | none§

    Source

    The write timeout; none for none.

  • pub fn set_reuse_address(self, on: bool) throws (IoError)§

    Source

    SO_REUSEADDR.

  • pub fn reuse_address(self) throws (IoError) -> bool§

    Source

    SO_REUSEADDR.

  • pub fn set_reuse_port(self, on: bool) throws (IoError)§

    Source

    SO_REUSEPORT; Unsupported off Unix.

  • pub fn reuse_port(self) throws (IoError) -> bool§

    Source

    SO_REUSEPORT.

  • pub fn set_nodelay(self, on: bool) throws (IoError)§

    Source

    TCP_NODELAY.

  • pub fn nodelay(self) throws (IoError) -> bool§

    Source

    TCP_NODELAY.

  • pub fn set_keepalive(self, alive: Duration | none) throws (IoError)§

    Source

    Keepalive probes after alive idle (whole seconds); none = off.

  • pub fn set_broadcast(self, on: bool) throws (IoError)§

    Source

    SO_BROADCAST.

  • pub fn broadcast(self) throws (IoError) -> bool§

    Source

    SO_BROADCAST.

  • pub fn set_recv_buffer_size(self, size: usize) throws (IoError)§

    Source

    SO_RCVBUF (the OS may round it, and Linux doubles it).

  • pub fn recv_buffer_size(self) throws (IoError) -> usize§

    Source

    SO_RCVBUF, as the OS reports it.

  • pub fn set_send_buffer_size(self, size: usize) throws (IoError)§

    Source

    SO_SNDBUF.

  • pub fn send_buffer_size(self) throws (IoError) -> usize§

    Source

    SO_SNDBUF, as the OS reports it.

  • pub fn set_ttl(self, ttl: u32) throws (IoError)§

    Source

    IP_TTL of an IPv4 socket.

  • pub fn ttl(self) throws (IoError) -> u32§

    Source

    IP_TTL.

  • pub fn set_only_v6(self, on: bool) throws (IoError)§

    Source

    IPV6_V6ONLY: an IPv6 socket that takes no IPv4 traffic.

  • pub fn only_v6(self) throws (IoError) -> bool§

    Source

    IPV6_V6ONLY.

  • pub fn set_linger(self, dur: Duration | none) throws (IoError)§

    Source

    SO_LINGER (whole seconds): close waits that long for unsent data; none = off.

  • pub fn linger(self) throws (IoError) -> Duration | none§

    Source

    SO_LINGER in whole seconds; none when off.

  • pub fn try_clone(self) throws (IoError) -> Socket§

    Source

    A second handle to the same socket.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error; later calls fail with InvalidInput.

Trait implementations 8

ReadHalfSource

pub struct ReadHalf<T>

The read half of a split connection (TcpStream::split, UnixStream::split, tls::Client::split, tls::Server::split): it owns the reading direction. Send it to another task or thread while the WriteHalf writes; close it, or rejoin the two with unsplit. The socket closes when both halves are closed.

  • pub fn close(self) throws (IoError)§

    Source

    Close the read half; the socket closes once the write half is closed too. Throws the OS's error of that close.

  • pub fn shutdown(self, how: Shutdown) throws (IoError)§

    Source

    Shut down reading, writing or both of the socket the halves share (TLS: close_notify first for writing). Both wakes a write blocked on the other half too.

  • pub async fn shutdown_async(ref self, how: Shutdown) throws (IoError)§

    Source

    shutdown, awaiting close_notify on TLS instead of blocking.

  • pub fn unsplit(self, w: WriteHalf<TcpStream>) -> TcpStream§

    Source

    The connection again, from this half and the WriteHalf that split gave with it. Panics on a write half of another connection.

Trait implementations 7
  • unsafe impl<T> Send for ReadHalf<T>
  • impl<T> Debug for ReadHalf<T>
  • impl<T> Read for ReadHalf<T>
  • impl<T> AsyncRead for ReadHalf<T>
  • impl<T> Close for ReadHalf<T>
  • impl<T> AsyncClose for ReadHalf<T>
  • impl<T> Drop for ReadHalf<T>

TcpListenerSource

pub struct TcpListener

A listening TCP socket.

  • pub fn bind<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpListener§

    Source

    Bind and listen on the first address of addr that works (SO_REUSEADDR off Windows, backlog 128). Port 0 picks one: see local_addr.

  • pub fn inherited() -> List<TcpListener>§

    Source

    The listening sockets the host handed this program, in order: WASI's pre-opened sockets (wasmtime -S tcplisten=ADDR, preview 1: wasm32-wasip1-threads), systemd socket activation (LISTEN_FDS) on Unix; none on Windows. Where a program cannot bind sockets itself, these are how it serves.

  • pub fn accept(self) throws (IoError) -> (TcpStream, SocketAddr)§

    Source

    The next connection and its peer, blocking until one arrives.

  • pub async fn accept_async(ref self) throws (IoError) -> (TcpStream, SocketAddr)§

    Source

    accept that suspends the task until a connection arrives.

  • pub fn local_addr(self) throws (IoError) -> SocketAddr§

    Source

    The bound address (the port picked when bound to port 0).

  • pub fn set_ttl(self, ttl: u32) throws (IoError)§

    Source

    Set IP_TTL.

  • pub fn ttl(self) throws (IoError) -> u32§

    Source

    IP_TTL.

  • pub fn try_clone(self) throws (IoError) -> TcpListener§

    Source

    A second descriptor on the same socket (dup).

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make the blocking calls throw WouldBlock instead of waiting.

  • pub const fn incoming(ref self) -> Incoming§

    Source

    try for s in l.incoming() { .. }: connections forever; a failed accept ends the loop with its error. A view of the listener: it stays in the listener's scope, and its owner still closes it.

  • pub const fn into_incoming(self) -> io::Owned<Incoming, TcpListener>§

    Source

    incoming owning the listener: it may leave the scope or move to a task, and closes the listener with itself.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error.

Trait implementations 5

TcpStreamSource

pub struct TcpStream

A TCP connection. It has one owner (let b = a moves it); close it with try s.close() or using.

  • pub fn connect<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpStream§

    Source

    Connect to the first address of addr that accepts, blocking until the handshake is done.

  • pub fn connect_timeout(addr: SocketAddr, dur: Duration) throws (IoError) -> TcpStream§

    Source

    Connect to addr, giving up after dur.

  • pub async fn connect_async<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpStream§

    Source

    connect that suspends the task during each handshake.

  • pub fn peer_addr(self) throws (IoError) -> SocketAddr§

    Source

    The remote end's address.

  • pub fn local_addr(self) throws (IoError) -> SocketAddr§

    Source

    This end's address.

  • pub fn shutdown(self, how: Shutdown) throws (IoError)§

    Source

    Shut down the read half, the write half or both; the peer reads end of stream after Write.

  • pub async fn shutdown_async(ref self, how: Shutdown) throws (IoError)§

    Source

    As shutdown, which never waits.

  • pub fn set_nodelay(self, nodelay: bool) throws (IoError)§

    Source

    Turn Nagle's algorithm off (TCP_NODELAY) or back on.

  • pub fn nodelay(self) throws (IoError) -> bool§

    Source

    TCP_NODELAY.

  • pub fn set_keepalive(self, alive: Duration | none) throws (IoError)§

    Source

    Keepalive probes after alive idle (whole seconds); none = off.

  • pub fn set_ttl(self, ttl: u32) throws (IoError)§

    Source

    Set IP_TTL.

  • pub fn ttl(self) throws (IoError) -> u32§

    Source

    IP_TTL.

  • pub const fn set_read_timeout(self, dur: Duration | none)§

    Source

    Make a blocking read throw TimedOut after dur; none waits forever.

  • pub const fn set_write_timeout(self, dur: Duration | none)§

    Source

    Make a blocking write throw TimedOut after dur; none waits forever.

  • pub const fn read_timeout(self) -> Duration | none§

    Source

    The read timeout; none when reads wait forever.

  • pub const fn write_timeout(self) -> Duration | none§

    Source

    The write timeout; none when writes wait forever.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make the blocking calls throw WouldBlock instead of waiting.

  • pub fn try_clone(self) throws (IoError) -> TcpStream§

    Source

    A second descriptor on the same socket (dup), with this one's timeouts and blocking mode.

  • pub fn split(self) -> (ReadHalf<TcpStream>, WriteHalf<TcpStream>)§

    Source

    Split into a read half and a write half that two tasks or threads can use at once. Each half owns its direction and must be closed; ReadHalf::unsplit joins them again.

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error; later calls fail with InvalidInput.

Trait implementations 9

WriteHalfSource

pub struct WriteHalf<T>

The write half of a split connection: it owns the writing direction. Closing it ends the stream for the peer (shutdown(Write), after close_notify on TLS) while the read half reads on.

  • pub fn close(self) throws (IoError)§

    Source

    End the stream for the peer, or close the socket when the read half is closed already. Throws the OS's error.

  • pub fn shutdown(self, how: Shutdown) throws (IoError)§

    Source

    Shut down reading, writing or both of the socket the halves share (TLS: close_notify first for writing). Both wakes a read blocked on the other half, as shutdown(SHUT_RDWR) does.

  • pub async fn shutdown_async(ref self, how: Shutdown) throws (IoError)§

    Source

    shutdown, awaiting close_notify on TLS instead of blocking.

Trait implementations 7
  • unsafe impl<T> Send for WriteHalf<T>
  • impl<T> Debug for WriteHalf<T>
  • impl<T> Write for WriteHalf<T>
  • impl<T> AsyncWrite for WriteHalf<T>
  • impl<T> Close for WriteHalf<T>
  • impl<T> AsyncClose for WriteHalf<T>
  • impl<T> Drop for WriteHalf<T>

UdpSocketSource

pub struct UdpSocket

A UDP socket. It has one owner: let b = a moves it.

  • pub fn bind<A: ToSocketAddrs>(addr: A) throws (IoError) -> UdpSocket§

    Source

    Bind the first address of addr that works.

  • pub fn send_to<B: AsBytes, A: ToSocketAddrs>(self, buf: B, addr: A) throws (IoError) -> usize§

    Source

    Send the datagram buf to the first address of addr; bytes sent.

  • pub async fn send_to_async<B: AsBytes, A: ToSocketAddrs>(ref self, buf: B, addr: A) throws (IoError) -> usize§

    Source

    send_to, suspending the task instead of blocking.

  • pub fn recv_from(self, buf: SliceMut<u8>) throws (IoError) -> (usize, SocketAddr)§

    Source

    The next datagram into buf[0..n] (truncated to buf.len()) and its sender.

  • pub async fn recv_from_async(ref self, buf: SliceMut<u8>) throws (IoError) -> (usize, SocketAddr)§

    Source

    recv_from that suspends the task until a datagram arrives.

  • pub fn connect<A: ToSocketAddrs>(self, addr: A) throws (IoError)§

    Source

    Fix the peer to the first address of addr that takes it: send / recv then talk to it only.

  • pub async fn connect_async<A: ToSocketAddrs>(ref self, addr: A) throws (IoError)§

    Source

    As connect: a UDP connect only records the peer, so it never waits (a name in addr is resolved as connect does).

  • pub fn send<B: AsBytes>(self, buf: B) throws (IoError) -> usize§

    Source

    Send buf as one datagram to the peer set by connect.

  • pub async fn send_async<B: AsBytes>(ref self, buf: B) throws (IoError) -> usize§

    Source

    send, suspending the task instead of blocking.

  • pub fn recv(self, buf: SliceMut<u8>) throws (IoError) -> usize§

    Source

    The next datagram from the connect peer into buf (truncated to buf.len()); its length.

  • pub async fn recv_async(ref self, buf: SliceMut<u8>) throws (IoError) -> usize§

    Source

    recv, suspending the task instead of blocking.

  • pub fn local_addr(self) throws (IoError) -> SocketAddr§

    Source

    The bound address.

  • pub fn peer_addr(self) throws (IoError) -> SocketAddr§

    Source

    The peer set by connect; throws without one.

  • pub fn set_broadcast(self, on: bool) throws (IoError)§

    Source

    Allow sending to broadcast addresses (SO_BROADCAST).

  • pub fn broadcast(self) throws (IoError) -> bool§

    Source

    SO_BROADCAST.

  • pub fn set_ttl(self, ttl: u32) throws (IoError)§

    Source

    Set IP_TTL.

  • pub fn ttl(self) throws (IoError) -> u32§

    Source

    IP_TTL.

  • pub fn join_multicast_v4(self, addr: Ipv4Addr, interface: Ipv4Addr) throws (IoError)§

    Source

    Join the multicast group addr on the interface whose address is interface (0.0.0.0: the default).

  • pub fn leave_multicast_v4(self, addr: Ipv4Addr, interface: Ipv4Addr) throws (IoError)§

    Source

    Leave the multicast group addr on interface.

  • pub fn set_multicast_loop_v4(self, on: bool) throws (IoError)§

    Source

    Whether this host receives its own multicast datagrams.

  • pub fn set_multicast_ttl_v4(self, ttl: u32) throws (IoError)§

    Source

    Hops a multicast datagram may take (IP_MULTICAST_TTL).

  • pub fn set_segment_size(self, size: u16) throws (IoError)§

    Source

    UDP_SEGMENT (GSO); Unsupported off Linux.

  • pub const fn set_read_timeout(self, dur: Duration | none)§

    Source

    Make a blocking read throw TimedOut after dur; none waits forever.

  • pub const fn set_write_timeout(self, dur: Duration | none)§

    Source

    Make a blocking write throw TimedOut after dur; none waits forever.

  • pub const fn read_timeout(self) -> Duration | none§

    Source

    The read timeout; none waits forever.

  • pub const fn write_timeout(self) -> Duration | none§

    Source

    The write timeout; none waits forever.

  • pub const fn set_nonblocking(self, nb: bool)§

    Source

    Make the blocking calls throw WouldBlock instead of waiting.

  • pub fn try_clone(self) throws (IoError) -> UdpSocket§

    Source

    A second descriptor on the same socket (dup).

  • pub fn close(self) throws (IoError)§

    Source

    Close now, throwing the OS's error.

Trait implementations 5

IncomingSource

pub struct Incoming

TcpListener::incoming: a view of the listener.

Trait implementations 4

Enums

IpAddrSource

pub enum IpAddr

An IPv4 or IPv6 address.

Trait implementations 5

SocketAddrSource

pub enum SocketAddr

An IPv4 or IPv6 socket address.

  • pub const fn new(ip: IpAddr, port: u16) -> SocketAddr§

    Source

    ip and port; an IPv6 one has flow info and scope id 0.

  • pub const fn ip(self) -> IpAddr§

    Source

    The IP address.

  • pub const fn port(self) -> u16§

    Source

    The port.

  • pub const fn set_ip(ref self, ip: IpAddr)§

    Source

    An address of the other family replaces the whole address (flow info and scope id 0).

  • pub const fn set_port(ref self, port: u16)§

    Source

    Replace the port.

  • pub const fn is_ipv4(self) -> bool§

    Source

    true for an IPv4 address.

  • pub const fn is_ipv6(self) -> bool§

    Source

    true for an IPv6 address.

Trait implementations 6

DomainSource

pub enum Domain

An address family.

ShutdownSource

pub enum Shutdown

Which half of a connection shutdown closes.

SocketTypeSource

pub enum SocketType

A socket type.

  • SOCK_STREAM: TCP over IP.

  • Datagram§

    Source

    SOCK_DGRAM: UDP over IP.

  • SOCK_RAW: IP packets of one protocol (privileged; not on WASI).

Traits

ToSocketAddrsSource

pub trait ToSocketAddrs

What names the socket addresses to try, in order: a SocketAddr, "host:port" text (resolved, net::resolve), an (IpAddr, u16) pair or a list of addresses.

Functions

resolveSource

pub fn resolve(host: str) throws (IoError) -> List<SocketAddr>

Addresses of host: "name:port", "[v6]:port", a socket address, or a bare name / IP (port 0). The addresses come in the system resolver's order (its preferred address first), at most 32; a name with none throws NotFound.

tcp_connectSource

pub fn tcp_connect<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpStream

TcpStream::connect(addr).

tcp_connect_asyncSource

pub async fn tcp_connect_async<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpStream

TcpStream::connect_async(addr).

tcp_listenSource

pub fn tcp_listen<A: ToSocketAddrs>(addr: A) throws (IoError) -> TcpListener

TcpListener::bind(addr).

udp_bindSource

pub fn udp_bind<A: ToSocketAddrs>(addr: A) throws (IoError) -> UdpSocket

UdpSocket::bind(addr).