JSONRPC2 v0.3.0 JSONRPC2.Servers.TCP

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

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

Functions

child_spec(handler, port, opts \\ [])

Specs

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.
start_listener(handler, port, opts \\ [])

Specs

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.
stop(name)

Specs

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

Stop the server with name.