partisan_peer_socket (partisan v5.0.3)

View Source

Wrapper that allows transparent usage of plain TCP or TLS socket for peer connections.

This module also implements the monotonic channel functionality.

Summary

Functions

Wraps a TCP socket with the appropriate information for transceiving on and controlling the socket later. If TLS/SSL is enabled, this performs the socket upgrade/negotiation before returning the wrapped socket.

Returns the wrapped socket from within the connection.

Types

options/0

-type options() :: [gen_tcp:option()] | map().

reason/0

-type reason() :: closed | inet:posix().

t/0

-type t() ::
          #partisan_peer_socket{socket :: gen_tcp:socket() | ssl:sslsocket() | socket:socket(),
                                transport :: gen_tcp | ssl,
                                control :: inet | ssl,
                                monotonic :: boolean()}.

Functions

accept(TCPSocket)

-spec accept(gen_tcp:socket()) -> t().

Wraps a TCP socket with the appropriate information for transceiving on and controlling the socket later. If TLS/SSL is enabled, this performs the socket upgrade/negotiation before returning the wrapped socket.

close(Partisan_peer_socket)

-spec close(t()) -> ok.

See also: gen_tcp:close/1, ssl:close/1.

connect(Address, Port, Options)

-spec connect(inet:socket_address() | inet:hostname(), inet:port_number(), options()) ->
                 {ok, t()} | {error, inet:posix()}.

See also: gen_tcp:connect/3, ssl:connect/3.

connect(Address, Port, Options, Timeout)

-spec connect(inet:socket_address() | inet:hostname(), inet:port_number(), options(), timeout()) ->
                 {ok, t()} | {error, inet:posix()}.

connect(Address, Port, Options, Timeout, PartisanOptions)

-spec connect(inet:socket_address() | inet:hostname(),
              inet:port_number(),
              options(),
              timeout(),
              map() | list()) ->
                 {ok, t()} | {error, inet:posix()}.

recv(Conn, Length)

-spec recv(t(), integer()) -> {ok, iodata()} | {error, reason()}.

See also: gen_tcp:recv/2, ssl:recv/2.

recv(Partisan_peer_socket, Length, Timeout)

-spec recv(t(), integer(), timeout()) -> {ok, iodata()} | {error, reason()}.

See also: gen_tcp:recv/3, ssl:recv/3.

send(Partisan_peer_socket, Data)

-spec send(t(), iodata()) -> ok | {error, reason()}.

See also: gen_tcp:send/2, ssl:send/2.

setopts(Partisan_peer_socket, Options)

-spec setopts(t(), options()) -> ok | {error, inet:posix()}.

See also: inet:setopts/2, ssl:setopts/2.

socket(Conn)

-spec socket(t()) -> gen_tcp:socket() | ssl:sslsocket().

Returns the wrapped socket from within the connection.