Ankh.Transport protocol (ankh v0.17.0)

Transport interface

Link to this section Summary

Types

Transport data

Transport message

Transport options

Size

Socket

t()

Transport socket

Functions

Accepts a client connection

Closes the connection

Handles transport messages

Returns the transport negotiated protocol if any, nil otherwise

Creates a new transport with the passed socket

Link to this section Types

@type data() :: binary()

Transport data

@type msg() :: tuple()

Transport message

@type options() :: keyword()

Transport options

@type size() :: non_neg_integer()

Size

@type socket() :: any()

Socket

@type t() :: struct()

Transport socket

Link to this section Functions

Link to this function

accept(transport, options)

@spec accept(t(), options()) :: {:ok, t()} | {:error, any()}

Accepts a client connection

Link to this function

close(transport)

@spec close(t()) :: {:ok, t()} | {:error, any()}

Closes the connection

Link to this function

connect(transport, uri, timeout, options)

@spec connect(t(), URI.t(), timeout(), options()) :: {:ok, t()} | {:error, any()}

Connects to an host

Link to this function

handle_msg(transport, message)

@spec handle_msg(t(), any()) :: {:ok, iodata()} | {:error, any()}

Handles transport messages

Link to this function

negotiated_protocol(transport)

@spec negotiated_protocol(t()) ::
  {:ok, String.t()} | {:error, :protocol_not_negotiated}

Returns the transport negotiated protocol if any, nil otherwise

Link to this function

new(transport, socket)

@spec new(t(), socket()) :: {:ok, t()} | {:error, any()}

Creates a new transport with the passed socket

Link to this function

recv(transport, size, timeout)

@spec recv(t(), size(), timeout()) :: {:ok, iodata()} | {:error, any()}

Receives data

Link to this function

send(transport, data)

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

Sends data