transport v0.1.0 Transport.Tcp View Source

implements a tcp transport strategy.

Link to this section Summary

Server Functions

Callback implementation for Transport.accept/2.

Callback implementation for Transport.handshake/2.

Callback implementation for Transport.listen/2.

Functions

Callback implementation for Transport.recv/2, via :gen_tcp.recv/2.

Callback implementation for Transport.send/2, via :gen_tcp.send/2

Link to this section Types

Link to this section Server Functions

Link to this function

accept(sock, timeout)

View Source
accept(socket(), timeout()) :: {:ok, socket()} | {:error, term()}

Callback implementation for Transport.accept/2.

Link to this function

handshake(socket, opts!)

View Source
handshake(:inet.socket(), keyword()) :: {:ok, Api.socket()}

Callback implementation for Transport.handshake/2.

Does not request the client-side for an upgrade to an authenticated or encrypted channel, but this is also where you should set post-connection options (such as setting active: true)

Link to this function

listen(port, opts \\ [])

View Source
listen(:inet.port_number(), keyword()) :: {:ok, socket()} | {:error, term()}

Callback implementation for Transport.listen/2.

NB: Transport.Tcp defaults to using a binary tcp port.

Link to this section Client Functions

Link to this function

connect(host, port, opts! \\ [])

View Source
connect(term(), :inet.port_number(), keyword()) ::
  {:ok, socket()} | {:error, term()}

Callback implementation for Transport.connect/3.

Link to this function

upgrade(socket, opts!)

View Source
upgrade(socket(), keyword()) :: {:ok, :inet.socket()} | {:error, term()}

Callback implementation for Transport.upgrade/2.

Does not perform any cryptographic authentication, but this is where you should set post-connection options (such as setting active: true)

Link to this section Functions

Link to this function

recv(sock, length)

View Source
recv(socket(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}

Callback implementation for Transport.recv/2, via :gen_tcp.recv/2.

Link to this function

recv(sock, length, timeout)

View Source
recv(socket(), non_neg_integer(), timeout()) ::
  {:ok, binary()} | {:error, term()}

Callback implementation for Transport.recv/3, via :gen_tcp.recv/3.

Link to this function

send(sock, content)

View Source
send(socket(), iodata()) :: :ok | {:error, term()}

Callback implementation for Transport.send/2, via :gen_tcp.send/2