Xirsys.Sockets.DatagramServer (xturn_sockets v2.2.0)

View Source

Datagram listener that drains every whole packet from each inbound datagram.

Default transport is Transport.UDP. Multi-tier pipelines can keep per-peer session state; otherwise each datagram is framed independently.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns {server_ip, server_port} for the bound listener.

Bound port of a running server (useful when :port was 0).

Returns the listen socket owned by pid.

Opens a datagram listener.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

endpoint(pid)

@spec endpoint(pid()) :: {:inet.ip_address(), :inet.port_number()}

Returns {server_ip, server_port} for the bound listener.

port(pid)

Bound port of a running server (useful when :port was 0).

Parameters

socket(pid)

@spec socket(pid()) :: term()

Returns the listen socket owned by pid.

Used when a reply must be sent from a different local endpoint than the socket that received the datagram (RFC 5780 CHANGE-REQUEST).

start_link(opts)

Opens a datagram listener.

Parameters

opts is a keyword list:

  • :ip / :port - bind address (required)
  • :transport - transport module (default Transport.UDP)
  • :pipeline - pipeline module, or omit and pass :accumulator + :handler
  • :listen_opts - extra options forwarded to listen/3
  • :assigns - map copied onto each datagram's Conn
  • :handler_state - initial handler state for stateless datagrams
  • :tick_interval_ms - optional drain tick (also enables per-peer sessions when the pipeline has more than :root)