JSONRPC2 v1.2.0 JSONRPC2.Servers.TCP View Source

A server for JSON-RPC 2.0 using a line-based TCP transport.

Link to this section Summary

Functions

Returns a supervisor child spec for the given handler on port with opts.

Start a server with the given handler on port with opts.

Stop the server with name.

Link to this section Functions

Link to this function

child_spec(handler, port, opts \\ []) View Source
child_spec(module(), :inet.port_number(), Keyword.t()) :: {:ok, pid()}

Returns a supervisor child spec for the given handler on port with opts.

Allows you to embed a server directly in your app's supervision tree, rather than letting Ranch handle it.

Available options:

  • name - a unique name that can be used to stop the server later. Defaults to the value of handler.
  • num_acceptors - number of acceptor processes to start. Defaults to 100.
  • transport - ranch transport to use. Defaults to :ranch_tcp.
  • transport_opts - ranch transport options. For :ranch_tcp, see here.
  • timeout - disconnect after this amount of milliseconds without a packet from a client. Defaults to 1 hour.
Link to this function

start_listener(handler, port, opts \\ []) View Source
start_listener(module(), :inet.port_number(), Keyword.t()) :: {:ok, pid()}

Start a server with the given handler on port with opts.

Available options:

  • name - a unique name that can be used to stop the server later. Defaults to the value of handler.
  • num_acceptors - number of acceptor processes to start. Defaults to 100.
  • transport - ranch transport to use. Defaults to :ranch_tcp.
  • transport_opts - ranch transport options. For :ranch_tcp, see here.
  • timeout - disconnect after this amount of milliseconds without a packet from a client. Defaults to 1 hour.
Link to this function

stop(name) View Source
stop(atom()) :: :ok | {:error, :not_found}

Stop the server with name.