Skip to content

std.net

tcp/udp facade over net.os/addr/socket/tcp/udp; re-exports their types call net::init() once per process before any socket call

pub NetError :: os::NetError
pub SocketAddr :: addr::SocketAddr
pub TcpStream :: tcp::TcpStream
pub TcpListener :: tcp::TcpListener
pub Accepted :: tcp::Accepted
pub UdpSocket :: udp::UdpSocket
pub Datagram :: udp::Datagram
pub init :: fn() -> void ! NetError

init winsock; once, before any socket call

pub shutdown :: fn()

tear down winsock; optional, at exit

pub last_error :: fn() -> i32

last winsock error on this thread (WSAGetLastError)

pub connect :: fn(sa: SocketAddr) -> TcpStream ! NetError

connect to sa (client)

pub listen :: fn(sa: SocketAddr) -> TcpListener ! NetError

bind + listen on sa, backlog 16

pub resolve :: fn(a: *Arena, host: []const u8) -> addr::IpV4 ! NetError

ipv4 of host: dotted, localhost, or looked up (after init); files read into a windows: system resolver; linux: /etc/hosts, then resolv.conf servers, 2 s each

pub connect_host :: fn(a: *Arena, host: []const u8, port: u16) -> TcpStream ! NetError

resolve host, connect at port

pub udp_bind :: fn(sa: SocketAddr) -> UdpSocket ! NetError

UdpSocket bound to sa