macula_quic (macula v0.20.3)

View Source

Main API module for Macula QUIC transport. Provides a simplified wrapper around the quicer library.

Summary

Functions

Accept an incoming connection on a listener. After accepting, the connection needs handshake to complete.

Accept an incoming stream on a connection.

Send data on a stream asynchronously (non-blocking). This returns immediately without waiting for QUIC flow control.

Close a listener, connection, or stream. Tries stream, then connection, then listener close in sequence.

Connect to a QUIC server. Options: {alpn, [Protocol]} - List of ALPN protocols {verify, none | verify_peer} - Certificate verification mode {cacertfile, Path} - CA certificate bundle for verification (v0.16.3+) {depth, N} - Max certificate chain depth (v0.16.3+) {server_name_indication, Host} - SNI hostname (v0.16.3+) {idle_timeout_ms, N} - Connection idle timeout in milliseconds {keep_alive_interval_ms, N} - Keep-alive PING interval in milliseconds

Start a QUIC listener on the specified port. Options: {cert, CertFile} - Path to PEM certificate file {key, KeyFile} - Path to PEM private key file {alpn, [Protocol]} - List of ALPN protocols (e.g., ["macula"]) {peer_unidi_stream_count, N} - Max unidirectional streams {peer_bidi_stream_count, N} - Max bidirectional streams {idle_timeout_ms, N} - Connection idle timeout in milliseconds {keep_alive_interval_ms, N} - Keep-alive PING interval in milliseconds

Open a new bidirectional stream on a connection.

Get the peer's address from a stream or connection handle. Returns {ok, {IP, Port}} on success or {error, Reason} on failure. Works with both stream and connection handles.

Receive data from a stream (blocking).

Send data on a stream (blocking).

Functions

accept(ListenerPid, Timeout)

-spec accept(reference(), timeout()) -> {ok, reference()} | {error, term()}.

Accept an incoming connection on a listener. After accepting, the connection needs handshake to complete.

accept_stream(ConnPid, Timeout)

-spec accept_stream(reference(), timeout()) -> {ok, reference()} | {error, term()}.

Accept an incoming stream on a connection.

async_send(StreamPid, Data)

-spec async_send(reference(), iodata()) -> ok | {error, term()}.

Send data on a stream asynchronously (non-blocking). This returns immediately without waiting for QUIC flow control.

close(Pid)

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

Close a listener, connection, or stream. Tries stream, then connection, then listener close in sequence.

connect(Host, Port, Opts, Timeout)

-spec connect(string() | inet:ip_address(), inet:port_number(), list(), timeout()) ->
                 {ok, reference()} | {error, term()}.

Connect to a QUIC server. Options: {alpn, [Protocol]} - List of ALPN protocols {verify, none | verify_peer} - Certificate verification mode {cacertfile, Path} - CA certificate bundle for verification (v0.16.3+) {depth, N} - Max certificate chain depth (v0.16.3+) {server_name_indication, Host} - SNI hostname (v0.16.3+) {idle_timeout_ms, N} - Connection idle timeout in milliseconds {keep_alive_interval_ms, N} - Keep-alive PING interval in milliseconds

listen(Port, Opts)

-spec listen(inet:port_number(), list()) -> {ok, reference()} | {error, term()}.

Start a QUIC listener on the specified port. Options: {cert, CertFile} - Path to PEM certificate file {key, KeyFile} - Path to PEM private key file {alpn, [Protocol]} - List of ALPN protocols (e.g., ["macula"]) {peer_unidi_stream_count, N} - Max unidirectional streams {peer_bidi_stream_count, N} - Max bidirectional streams {idle_timeout_ms, N} - Connection idle timeout in milliseconds {keep_alive_interval_ms, N} - Keep-alive PING interval in milliseconds

open_stream(ConnPid)

-spec open_stream(reference()) -> {ok, reference()} | {error, term()}.

Open a new bidirectional stream on a connection.

peername(Handle)

-spec peername(term()) -> {ok, {inet:ip_address(), inet:port_number()}} | {error, term()}.

Get the peer's address from a stream or connection handle. Returns {ok, {IP, Port}} on success or {error, Reason} on failure. Works with both stream and connection handles.

recv(StreamPid, Timeout)

-spec recv(reference(), timeout()) -> {ok, binary()} | {error, term()}.

Receive data from a stream (blocking).

send(StreamPid, Data)

-spec send(reference(), iodata()) -> ok | {error, term()}.

Send data on a stream (blocking).