FixAlchemy.Transport (FIXAlchemy v0.2.0)

View Source

Socket operations over plain TCP or TLS, chosen by an atom.

A transport is :gen_tcp or :ssl. Every function takes it as its first argument, so a session holds the atom in its state and never branches on it.

Sockets are opened in active: :once mode. A caller that has finished handling a delivered packet calls activate_once/2 to ask for the next one.

Summary

Functions

Accept one connection, completing the TLS handshake when the transport is :ssl.

The transport an option set selects; tls: true selects :ssl.

Open a listening socket on port.

Types

socket()

@type socket() :: :gen_tcp.socket() | :ssl.sslsocket()

t()

@type t() :: :gen_tcp | :ssl

Functions

accept(atom, listen_socket, timeout)

@spec accept(t(), socket(), timeout()) :: {:ok, socket()} | {:error, term()}

Accept one connection, completing the TLS handshake when the transport is :ssl.

The returned socket belongs to the calling process until it hands it on with controlling_process/3.

activate_once(atom, socket)

@spec activate_once(t(), socket()) :: :ok | {:error, term()}

close(atom, socket)

@spec close(t(), socket()) :: :ok

controlling_process(atom, socket, pid)

@spec controlling_process(t(), socket(), pid()) :: :ok | {:error, term()}

from_opts(opts)

@spec from_opts(keyword()) :: t()

The transport an option set selects; tls: true selects :ssl.

listen(atom, port, opts)

@spec listen(t(), :inet.port_number(), keyword()) ::
  {:ok, socket()} | {:error, term()}

Open a listening socket on port.

port may be 0 to let the operating system choose one; read it back with listen_port/2.

listen_port(atom, socket)

@spec listen_port(t(), socket()) :: {:ok, :inet.port_number()} | {:error, term()}

peername(atom, socket)

@spec peername(t(), socket()) ::
  {:ok, {:inet.ip_address(), :inet.port_number()}} | {:error, term()}

send(atom, socket, data)

@spec send(t(), socket(), iodata()) :: :ok | {:error, term()}