Xirsys.Sockets.Connection (xturn_sockets v2.2.1)

View Source

Per-connection process: owns accumulator state and fully drains after each read.

Started by Acceptor via SockSupervisor. One process per accepted stream (TCP/TLS). Datagrams use DatagramServer instead.

Internal API. Started by the library acceptor; host applications normally configure pipelines on listeners rather than starting this GenServer directly.

What problem this solves

Stream sockets need a dedicated process to hold per-connection accumulator and handler state, re-arm {active, N} reads, and drain the full pipeline after every chunk so partial STUN/TURN frames never stall the acceptor.

RFCs

Summary

Functions

Temporary child spec so a dead connection is not restarted.

Starts a connection process for an already-accepted socket.

Functions

child_spec(init_arg)

Temporary child spec so a dead connection is not restarted.

Parameters

start_link(opts)

Starts a connection process for an already-accepted socket.

Parameters

opts is a keyword list:

  • :transport - Xirsys.Sockets.Transport module (required)
  • :socket - accepted client socket (required)
  • :pipeline - pipeline module, or omit and pass :accumulator + :handler
  • :listener - acceptor pid
  • :assigns - map copied onto Conn
  • :handler_state - initial handler state when handle_connect/1 is absent
  • :tick_interval_ms - optional drain tick for reorder timeouts