Tortoise311.Transport behaviour (tortoise311 v0.11.1) View Source

Abstraction for working with network connections; this is done to normalize the :ssl and :gen_tcp modules, so they get a similar interface.

This work has been heavily inspired by the Ranch project by NineNines.

Link to this section Summary

Functions

Create a new Transport specification used by the Connection process to log on to the MQTT server. This allow us to filter the options passed to the connection type, and guide the user to connect to the individual transport type.

Link to this section Types

Specs

opts() :: any()

Specs

socket() :: any()

Specs

stats() :: any()

Specs

t()

Link to this section Callbacks

Specs

accept(socket(), timeout()) ::
  {:ok, socket()} | {:error, :closed | :timeout | atom()}
Link to this callback

accept_ack(socket, timeout)

View Source

Specs

accept_ack(socket(), timeout()) :: :ok

Specs

close(socket()) :: :ok
Link to this callback

connect(charlist, port_number, opts, timeout)

View Source

Specs

connect(charlist(), :inet.port_number(), opts(), timeout()) ::
  {:ok, socket()} | {:error, atom()}
Link to this callback

controlling_process(socket, pid)

View Source

Specs

controlling_process(socket(), pid()) ::
  :ok | {:error, :closed | :now_owner | atom()}

Specs

getopts(socket(), [atom()]) :: {:ok, opts()} | {:error, atom()}

Specs

getstat(socket()) :: {:ok, stats()} | {:error, atom()}

Specs

getstat(socket(), [atom()]) :: {:ok, stats()} | {:error, atom()}

Specs

listen(opts()) :: {:ok, socket()} | {:error, atom()}

Specs

new(opts()) :: t()

Specs

peername(socket()) ::
  {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, atom()}
Link to this callback

recv(socket, non_neg_integer, timeout)

View Source

Specs

recv(socket(), non_neg_integer(), timeout()) ::
  {:ok, any()} | {:error, :closed | :timeout | atom()}

Specs

send(socket(), iodata()) :: :ok | {:error, atom()}

Specs

setopts(socket(), opts()) :: :ok | {:error, atom()}

Specs

shutdown(socket(), :read | :write | :read_write) :: :ok | {:error, atom()}

Specs

sockname(socket()) ::
  {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, atom()}

Link to this section Functions

Specs

new({atom(), [term()]}) :: t()

Create a new Transport specification used by the Connection process to log on to the MQTT server. This allow us to filter the options passed to the connection type, and guide the user to connect to the individual transport type.