PeerNet.Acceptor (PeerNet v0.1.0)

Copy Markdown View Source

TCP listener for one PeerNet instance. Accepts inbound connections and spawns one PeerNet.Connection per accepted socket.

The acceptor is intentionally tiny — all the state lives on the per-connection process. The acceptor's only job is to call :gen_tcp.accept/1 in a loop and hand each accepted socket off to a fresh connection process.

Bind on port 0 to let the OS pick an ephemeral port; read it back with port/1 afterwards (used in tests and in places where the listener's address needs to be advertised externally).

Summary

Functions

Returns a specification to start this module under a supervisor.

Return the OS-assigned listen port (resolved from port: 0).

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

port(server \\ __MODULE__)

@spec port(GenServer.server()) :: :inet.port_number()

Return the OS-assigned listen port (resolved from port: 0).

start_link(opts)