Create a TCP server that is bound to addr,
listening for incoming connections.
If addr is the IPv6 wildcard address [::]
and dual_stack is true (true by default),
the server will work in dual stack mode,
accepting connections from both IPv4 clients and IPv6 clients.
The address of IPv4 clients are represented via IPv4-mapped IPv6 address.
If addr is not [::], dual_stack is ignored.
If the port of addr is zero, the server will be bound to a random port,
assigned by the operating system.
The actual listen address can be retrieved via .addr().
If reuse_addr is true (false by default),
the SO_REUSEADDR option will be enabled on the server,
allowing binding to addr even if there are still
dead-ish TIME_WAIT sockets on that address.
On Windows, TIME_WAIT sockets are always ignored,
so the behavior is always reuse_addr=true and reuse_addr will be ignored.
On MacOS (BSD), reuse_addr has the extra side effect that
a server binding to a specific address may "steal" the specific interface
from a previous wildcard bind (0.0.0.0),
and similarly a server binding to a wildcard address can bind to
the remaining interfaces if a bind to a specific interface already exists.
This side effect cannot be isolated, so reuse_addr should be used with this in mind.
If reuse_port_lb is true (false by default), SO_REUSEPORT is enabled
so several sockets — typically one per worker process — can bind the same
address at once while the kernel load-balances incoming connections across
them. This is the usual basis for a multi-process server: a supervisor
execs N workers, each binds the same address with this option, and the
kernel spreads connections, so no socket needs to be shared between processes.
The load-balancing semantic is Linux-only. SO_REUSEPORT also exists on the
BSDs and MacOS, but there it does not evenly distribute connections — which
socket accepts a given connection is unspecified — so reuse_port_lb takes
effect only on Linux, including Wasm hosted by Moonrun on Linux, and is
ignored everywhere else (BSD, MacOS, Windows).