HL7v2.MLLP.Listener (HL7v2 v3.10.1)

Copy Markdown View Source

MLLP TCP listener using Ranch 2.x.

Starts a TCP (or TLS) listener that accepts MLLP connections and dispatches messages to the configured handler module.

Options

  • :port (required) — TCP port to listen on. Use 0 for OS-assigned port.
  • :handler (required) — module implementing HL7v2.MLLP.Handler.
  • :handler_state — arbitrary term passed to the handler in metadata.
  • :ref — Ranch listener reference (default: auto-generated atom).
  • :num_acceptors — number of acceptor processes (default: 10).
  • :tls — keyword list of TLS options. When present, Ranch uses :ranch_ssl instead of :ranch_tcp. See HL7v2.MLLP.TLS for helpers.
  • :timeout — idle connection timeout in milliseconds (default: 60_000).
  • :max_message_size — maximum MLLP message buffer size in bytes per connection (default: 10_485_760 — 10 MB). Connections exceeding this limit are closed.
  • :handler_timeout — maximum time in milliseconds for the handler to process a single message (default: 60_000). If exceeded, the handler process is killed and the connection continues.

Examples

{:ok, pid} = HL7v2.MLLP.Listener.start_link(
  port: 2575,
  handler: MyHandler
)

# Get the assigned port (useful when port: 0)
port = HL7v2.MLLP.Listener.port(pid)

# Stop the listener
HL7v2.MLLP.Listener.stop(pid)

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the port the listener is bound to.

Starts an MLLP listener.

Stops an MLLP listener.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

port(server)

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

Returns the port the listener is bound to.

Useful when the listener was started with port: 0 for OS-assigned ports.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts an MLLP listener.

See module documentation for available options.

stop(server)

@spec stop(GenServer.server()) :: :ok

Stops an MLLP listener.