View Source Modbuzz.TCP.TransportBehaviour behaviour (Modbuzz v0.1.2)

This behaviour provides the exact same interface as :gen_tcp.

We use identifier() as socket type for unit tests.

Summary

Callbacks

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

connect(address, port, opts, timeout)

View Source
@callback connect(
  address :: :inet.socket_address() | :inet.hostname(),
  port :: :inet.port_number(),
  opts :: [:inet.inet_backend() | :gen_tcp.connect_option()],
  timeout :: timeout()
) :: {:ok, socket :: identifier()} | {:error, :timeout | :inet.posix()}
Link to this callback

recv(socket, length, timeout)

View Source
@callback recv(socket :: identifier(), length :: non_neg_integer(), timeout :: timeout()) ::
  {:ok, binary()} | {:error, :closed | :inet.posix()}
@callback send(socket :: identifier(), packet :: iodata()) ::
  :ok | {:error, :closed | {:timeout, rest_data :: binary()} | :inet.posix()}