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. Use0for OS-assigned port.:handler(required) — module implementingHL7v2.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_sslinstead of:ranch_tcp. SeeHL7v2.MLLP.TLSfor 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
Returns a specification to start this module under a supervisor.
See Supervisor.
@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.
@spec start_link(keyword()) :: GenServer.on_start()
Starts an MLLP listener.
See module documentation for available options.
@spec stop(GenServer.server()) :: :ok
Stops an MLLP listener.