net
import net
The net module provides networking primitives for Transmission Control
Protocol and User Datagram Protocol communication as well as IP address
manipulation interfaces.
TcpStreamcommunicates over TCP.UdpSocketcommunicates over UDP.UnixStreamcommunicates over a unix domain socket, which is a path on the filesystem rather than an address on the network.Ipparses, formats and classifies IP addresses.SocketAddrpairs an IP address with a port.net.tlswraps aTcpStreamin Transport Layer Security.net.dtlsprovides Datagram Transport Layer Security over UDP.net.pollwaits on many sockets at once.net.resolverasks the domain name system questions of its own.
The net API
Every public name in net, wherever it is declared. Each links to the
page that documents it.
| Name | Kind | Summary |
|---|---|---|
net.Acceptor | class | An accept loop that never parks the thread inside accept(). |
net.ERROR | constant | Readiness only: the socket has failed, or its handle can no longer supply a descriptor because it was closed,… |
net.HANGUP | constant | Readiness only: the peer has closed its end. |
net.Ip | class | Either an Ipv4 or an Ipv6, for code that needs to accept and work with addresses of either family without… |
net.Ipv4 | class | An IPv4 address, stored internally as four octets in network (i.e. big-endian, most significant octet first)… |
net.Ipv6 | class | An IPv6 address, stored internally as eight 16-bit segments in network (i.e. big-endian, most significant… |
net.Poller | class | A set of sockets to watch, each under a token of your choosing. |
net.READABLE | constant | Interest: tell me when this socket has data to read, a connection to accept, or an end-of-stream to observe. |
net.Shutdown | class | Used with TcpStream.shutdown() to select which half (or both halves) of a full-duplex TCP connection to… |
net.SocketAddr | class | Either a SocketAddrV4 or a SocketAddrV6, for code that needs to accept and work with socket addresses of… |
net.SocketAddrV4 | class | An IPv4 address and port, e.g. 192.168.1.10:8080. |
net.SocketAddrV6 | class | An IPv6 address and port, e.g. [2001:db8::1]:8080, optionally carrying a zone/scope identifier (RFC 4007)… |
net.TcpStream | class | A TCP socket, in either its connected-stream or listening-server role. |
net.UdpSocket | class | A UDP socket, usable for both sending and receiving datagrams, either to/from a single fixed peer (after… |
net.UnixStream | class | A unix domain socket, connected or listening. |
net.WRITABLE | constant | Interest: tell me when this socket can be written to without blocking. |
net.dtls.DtlsConfig | class | The trust roots and optional certificate a DTLS handshake needs - the same idea as tls.TlsConfig, minus the… |
net.dtls.DtlsSocket | class | A DTLS socket, in either its connected (client or accepted-server) role or its listening role. |
net.is_supported | function | Whether unix domain sockets work on this machine. |
net.pair | function | Two sockets already connected to each other, with no path and nothing on the filesystem. |
net.resolve | function | Resolves address - a host:port string whose host may be a name or an IP literal - into every socket… |
net.resolver.CLASSES | constant | The classes a question can be asked in. |
net.resolver.Certification | class | A CAA record: which certificate authorities a domain allows to issue for it. |
net.resolver.MailExchange | class | One mail server for a domain, as an MX record names it. |
net.resolver.MalformedResponse | class | Something came back that is not a DNS message, or is one that contradicts itself. |
net.resolver.NameError | class | The name does not exist. |
net.resolver.NoServersError | class | The resolver has nowhere to send a query: no servers were given and the system has none configured. |
net.resolver.Question | class | The question a message asks, echoed back in the answer so a reply can be matched to what it replies to. |
net.resolver.RCODES | constant | What a server said about the question, by name. |
net.resolver.Record | class | One resource record: a name, what kind of thing it holds, how long it may be cached, and the thing itself. |
net.resolver.Resolver | class | Asks questions of the domain name system and reads the answers. |
net.resolver.ResolverError | class | The root of every error this module raises. |
net.resolver.ResolverTimeout | class | No server answered in time. |
net.resolver.Response | class | A whole answer: what was asked, what came back, and what the server said about it. |
net.resolver.ServerError | class | The server answered, and the answer was a refusal or a failure of its own. |
net.resolver.Service | class | Where a service lives, as an SRV record names it: the host and port, with the priority and weight that… |
net.resolver.StartOfAuthority | class | The authority record at the top of a zone, which says who publishes it and how long the rest of the world may… |
net.resolver.TYPES | constant | The record types this module knows how to read, by name. |
net.resolver.a | function | The IPv4 addresses of a name. |
net.resolver.aaaa | function | The IPv6 addresses of a name. |
net.resolver.addresses | function | Every address a name has, IPv4 first. |
net.resolver.build_query | function | Builds the bytes of a query. |
net.resolver.caa | function | Which certificate authorities a domain allows to issue for it. |
net.resolver.cname | function | The name this one is an alias for, or nil. |
net.resolver.exchange | function | Asks one server one question and returns what it said. |
net.resolver.flush | function | Empties the shared resolver’s cache. |
net.resolver.mx | function | The mail servers for a domain, lowest preference first. |
net.resolver.ns | function | The nameservers a domain is delegated to. |
net.resolver.parse_message | function | Turns the bytes of a message into a Response. |
net.resolver.ptr | function | The names an address points back at. |
net.resolver.query | function | Asks the shared resolver about one name and hands back the whole answer. |
net.resolver.resolve | function | The records of one type published for a name, through the shared resolver. |
net.resolver.reverse_name | function | The name an address’s records are published under. |
net.resolver.shared | function | The resolver the module-level functions use: one shared Resolver built from this machine’s own… |
net.resolver.soa | function | The authority record at the top of a name’s zone, or nil. |
net.resolver.srv | function | The hosts running a service, by priority and then by weight. |
net.resolver.system_search | function | The domain suffixes to try against a name that has no dots in it. |
net.resolver.system_servers | function | The nameservers this machine is configured to use, in the order the system lists them. |
net.resolver.txt | function | The text records of a name. |
net.resolver.use | function | Replaces the shared resolver, so that every module-level function goes through the one given instead. |
net.tls.PeerCertificate | class | The subset of a peer’s certificate that’s useful to inspect from Zuri code, without needing a full… |
net.tls.TlsConfig | class | The handful of choices a TLS handshake needs: which certificate authorities to trust, an optional certificate… |
net.tls.TlsStream | class | An established TLS connection, wrapping an already-connected TcpStream. |
Submodules
| Module | Reached as | Summary |
|---|---|---|
net.addr | net.* | Socket addresses: an IP address and a port. |
net.dtls | net.dtls.* | Datagram Transport Layer Security over a UdpSocket - the same certificate-based encryption and… |
net.ip | net.* | This module provides types for parsing, formatting, comparing and classifying IP addresses in both their IPv4… |
net.poll | net.* | Readiness polling: given a set of sockets, which of them can be read or written right now, without blocking. |
net.resolver | net.resolver.* | A DNS resolver, written in Zuri from the wire format up. |
net.tcp | net.* | This module provides a complete implementation of the Transmission Control Protocol as specified in IETF RFC… |
net.tls | net.tls.* | Transport Layer Security over a TcpStream, built on top of rustls. |
net.udp | net.* | This module provides a complete implementation of the User Datagram Protocol as specified in IETF RFC 768. |
net.unix | net.* | Unix domain sockets: the same stream interface as tcp, over a path on the filesystem rather than an address… |
2026, Richard Ore and Zuri contributors