Skip to main content

Module net

Module net 

Source
Expand description

The network, without the packing.

§What this wraps, and what it deliberately does not

net-stack answers two distinct kinds of request, and only the first is here:

  1. Plain requests to the service, addressed by a leading opcode byte - resolve a name, ping a host, run one TCP transaction, ask what our address is. That is this module.

  2. Invocations of a delegated resource capability (§7.10) - a UDP socket or a TCP listener is a real kernel capability that net-stack mints and grants, and using one means invoking it with an operation and a right. That is here now - docs/stdlib-design.md §8 argued for leaving it out, and the implementation has since crossed that boundary.

So: this module gets you a name resolved, a host pinged, a TCP request answered - AND a listening socket. Net::socket, Net::listen, Listener::accept and Conn are all here. This header said “It does not get you a listening socket. That boundary is deliberate”, which was true when written and is the opposite of the module below it now.

§A caution the rest of this library does not need

net-stack’s request protocol has moved 34 times in three releases. fs’s has not. Every opcode below therefore names the services/net-stack dispatch arm or constant it mirrors (line numbers are not cited: they rot), and the surface is kept to the operations with a demonstrated caller - because the cost of this module being wrong is not a compile error, it is a machine that quietly talks to the wrong port.

Re-exports§

pub use crate::addr::Ipv4;

Structs§

Conn
One accepted TCP connection, held as a capability.
Listener
A TCP listener, held as a capability.
Net
A handle to the network service.
Socket
A UDP socket, held as a capability.
Status
What the machine currently believes about the network.
Stream
One outbound TCP connection, held as a capability. See Net::connect.

Constants§

NET_SECS
A resolve or a TCP transaction crosses the network, so the five-second default is too tight. net-stack bounds a DNS resolve by the CLIENT’s patience rather than by an attempt count (its own words, and a fix on this branch), which means the number here IS the policy.
SOCKET_SECS
How long to wait for a datagram sent through a Socket.
TCP_SECS
How long to wait for a TCP transaction through Net::tcp.