Module libp2p_connection

This module defines the libp2p_connection behaviour.
Required callback functions: acknowledge/2, send/3, recv/3, close/1, close_state/1, fdset/1, fdclr/1, addr_info/1, session/1, set_idle_timeout/2, controlling_process/2.

Data Types

close_state()


close_state() = open | closed | pending

connection()


connection() = #connection{module = module(), state = any()}

Function Index

acknowledge/2
addr_info/1
close/1
close_state/1
controlling_process/2
fdclr/1
fdset/1
mk_async_sender/2
new/2
recv/1
recv/2
recv/3
send/2
send/3
session/1
set_idle_timeout/2
socket/1

Function Details

acknowledge/2


acknowledge(Connection::connection(), Ref::any()) -> ok


addr_info/1


addr_info(Connection::connection()) -> {string(), string()}


close/1


close(Connection::connection()) -> ok


close_state/1


close_state(Connection::connection()) -> close_state()


controlling_process/2


controlling_process(Conn::connection(), Pid::pid()) -> {ok, connection()} | {error, closed | not_owner | atom()}


fdclr/1


fdclr(Connection::connection()) -> ok | {error, term()}


fdset/1


fdset(Connection::connection()) -> ok | {error, term()}


mk_async_sender/2


mk_async_sender(Handler::pid(), Connection::libp2p_connection:connection()) -> function()


new/2


new(Module::atom(), State::any()) -> connection()


recv/1


recv(Conn::connection()) -> {ok, binary()} | {error, term()}


recv/2


recv(Conn::connection(), Length::non_neg_integer()) -> {ok, binary()} | {error, term()}


recv/3


recv(Connection::connection(), Length::non_neg_integer(), Timeout::non_neg_integer()) -> {ok, binary()} | {error, term()}


send/2


send(Connection::connection(), Data::iodata()) -> ok | {error, term()}


send/3


send(Connection::connection(), Data::iodata(), Timeout::non_neg_integer() | infinity) -> ok | {error, term()}


session/1


session(Connection::connection()) -> {ok, pid()} | {error, term()}


set_idle_timeout/2


set_idle_timeout(Connection::connection(), Timeout::pos_integer() | infinity) -> ok | {error, term()}


socket/1


socket(Connection::connection()) -> any()