Search documentation of macula

# macula_quic (macula v0.44.2)

View Source

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

# Summary

## Functions

accept(ListenerPid, Timeout)

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

accept_stream(ConnPid, Timeout)

Accept an incoming stream on a connection.

async_send(StreamPid, Data)

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

close(Pid)

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

connect(Host, Port, Opts, Timeout)

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)

Start a QUIC listener on a specific address and port.

open_stream(ConnPid)

Open a new bidirectional stream on a connection.

peername(Handle)

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)

Receive data from a stream (blocking).

send(StreamPid, Data)

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() | {string(), inet:port_number()}, list()) ->
                    {ok, reference()} | {error, term()}.

Start a QUIC listener on a specific address and port.

The first argument can be: - `Port` (integer) — binds to 0.0.0.0:Port (all IPv4, Docker-safe) - `{Address, Port}` — binds to Address:Port (IPv4 or IPv6) Address is a string: "0.0.0.0", "192.168.1.1", "2600:3c0e:e001:ec::100"

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).