Libp2p.Connection (libp2p_elixir v0.9.0)
One libp2p connection process.
Owns:
- TCP socket
- Noise secure channel state (
Libp2p.SecureConn) - Yamux session state (
Libp2p.Yamux.Session)
Exposes basic stream send/recv primitives used by higher-level protocol handlers.
Summary
Functions
Block until the connection has completed the upgrade pipeline.
Returns a specification to start this module under a supervisor.
Open a new outbound yamux stream.
Return the remote peer id (from Noise) once ready.
Set the process that will receive stream events.
Close (FIN) a yamux stream.
Receive bytes for a yamux stream (may return partial data).
Send bytes on a yamux stream.
Types
@type t() :: pid()
Functions
Block until the connection has completed the upgrade pipeline.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec open_stream(t()) :: {:ok, non_neg_integer()} | {:error, term()}
Open a new outbound yamux stream.
Return the remote peer id (from Noise) once ready.
@spec set_stream_handler(t(), non_neg_integer(), pid()) :: :ok
Set the process that will receive stream events.
@spec start_link(keyword()) :: GenServer.on_start()
@spec stream_close(t(), non_neg_integer()) :: :ok | {:error, term()}
Close (FIN) a yamux stream.
@spec stream_recv(t(), non_neg_integer(), timeout()) :: {:ok, binary()} | {:error, term()}
Receive bytes for a yamux stream (may return partial data).
@spec stream_send(t(), non_neg_integer(), binary()) :: :ok | {:error, term()}
Send bytes on a yamux stream.