View Source quicer (quicer v0.0.303)

Summary

Functions

Return ABI version of the library.

Accept new Connection (Server)

Accept new Connection (Server) with timeout

See also: accept/2.

Accept new stream on a existing connection with stream opts

Accept new stream on a existing connection with stream opts with timeout

Accept new stream on a existing connection with stream opts

async variant of close_stream/1, prefer to use async_shutdown_stream/4

See also: async_shutdown_stream/4, close_stream/4.

Initiate New Connection (Client)

Send data over a new local stream in the connection, return new stream handle if success.
Complete TLS handshake after accepted a Connection. Caller should expect to receive
  {quic, connected, connection_handle()}

See also: handshake/2.

async variant of send/2 Caller should NOT expect to receive
     {quic, send_complete, Stream, send_complete_flag()}
note, check send_complete_flag() to ensure it is delivered or not.
async variant of send/3 If QUICER_SEND_FLAG_SYNC is set , the caller should expect to receive {quic, send_complete, Stream, send_complete_flag()} note, check send_complete_flag() to ensure it is delivered or not.
Async starts the shutdown process and caller should expect for connection down message {quic, close, Conn}
async variant of shutdown_stream/4 Caller should expect to receive
     {quic, stream_closed, Stream, Flags}
Close connection with flag specified and application reason code.

See also: shutdown_connection/3.

Close connection with flag specified and application reason code with timeout

See also: shutdown_connection/4.

Close library.

close listener with listener handle
close a registration.
Normal shutdown stream with infinity timeout.

See also: close_stream/2.

Normal shutdown (App errno=0) Stream gracefully with timeout.

See also: close_stream/4.

Another name of shutdown stream for migration from tcp/ssl.

See also: close_stream/1, shutdown_stream/4.

Initiate New Connection (Client)

set controlling process for Connection/Stream. mimic ssl:controlling_process/2

See also: wait_for_handoff/2.

Pop out continuous data from the buffer start from the offset.
Get a list connections under global registration
Get a list of connections under registration handle
Get a list listeners under global registration
Get a list of listeners under registration handle
get registration name
get stream id with stream handle
Get connection/stream/listener opts mimic ssl:getopts/2
Get connection/stream/listener opts mimic ssl:getopt/2
get connection state mimic ssl:getstat/2
handoff_stream without post handoff data. see handoff_stream/3
Used by Old stream owner to handoff to the new stream owner. 1. The Stream will be put into passive mode. 2. Stream messages in the current owners process messages queue will be forwarded to the New Owner's mailbox in the same recv order. 3. Set the control process of the stream to the new owner. 4. A signal msg {handoff_done, Stream, PostHandoff} will be sent to the new owner. The new owner should block for this message before handle any stream data to ensure the ordering. 5. Revert stream active mode whatever handoff fail or success. also @see wait_for_handoff/2
Complete TLS handshake after accepted a Connection with 5s timeout (Server)

See also: accept/3, handshake/2.

Complete TLS handshake after accepted a Connection

See also: async_handshake/1, handshake/2.

Return true if stream open flags has unidirectional flag set

Start listen on Port or "HOST:PORT".

List listener with app name
list all listeners
Returns the protocol negotiated through ALPN or NPN extensions.
Create a new registration.

Quicer library must be opened before any use.

Peer Cert in DER-encoded binary mimic ssl:peername/1
get QUIC stack performance counters
Convert quic data event to quic_data for fpbuffer

Recv Data (Passive mode) Passive recv data from stream.

close Registraion. Reserved for future upgrade, don't use it.

See also: reg_open/1.

GRegistraion should be opened before calling traffic APIs.

Registraion should be opened before calling traffic APIs. Registraion creates application context, worker threads shared for all the connections

Send binary data over stream, blocking until send request is handled by the transport worker. either succeeded or cancelled
Send binary data over stream with send flags either succeeded or cancelled

Sending Unreliable Datagram

Set connection/stream/listener opts mimic ssl:setopt/2
Starts the shutdown process on a connection and block until it is finished.

See also: shutdown_connection/4.

Starts the shutdown process on a connection and block until it is finished. but with a timeout

See also: shutdown_connection/4.

Starts the shutdown process on a connection with shutdown flag and applications error with 5s timeout
Starts the shutdown process on a connection with shutdown flag and applications error with timeout

See also: shutdown_connection/1, shutdown_connection/2, shutdown_connection/3.

Shutdown a registration.
Shutdown a registration with error code and silent flag.
Shutdown stream gracefully, with infinity timeout

See also: shutdown_stream/1.

Shutdown stream gracefully, with app_errno 0

Start shutdown Stream process with flags and application specified error code.

Get socket name mimic ssl:sockname/1
start a listener process under supervisor tree
Start a stopped listener with listener handle.

Start new stream in connection, return new stream handle.

Stop a started listener which could be closed or restarted later.
terminate a listener process under supervisor tree
update fpbuffer and return *next* continuous data.
Used by new stream owner to wait for stream handoff complete. Use this for handoff the orphan stream *only*.

See also: controlling_process/2, handoff_stream/3.

Types

-type acceptor_opts() :: map().
-type alpn() :: string().
-type app_errno() :: non_neg_integer().
-type atom_reason() ::
    success | pending | continue | out_of_memory | invalid_parameter | invalid_state |
    not_supported | not_found | buffer_too_small | handshake_failure | aborted | address_in_use |
    connection_timeout | connection_idle | internal_error | connection_refused | protocol_error |
    ver_neg_error | unreachable | tls_error | user_canceled | alpn_neg_failure |
    stream_limit_reached.
-type conf_handle() :: reference().
-type conn_opts() ::
    quic_settings() |
    #{alpn := [string()],
      conn_callback => module(),
      cert => filelib:filename(),
      certfile => filelib:filename(),
      key => filelib:filename(),
      keyfile => filelib:filename(),
      password => string(),
      verify => none | peer,
      handle => connection_handle(),
      nst => binary(),
      cacertfile => filelib:filename(),
      sslkeylogfile => filelib:filename(),
      peer_bidi_stream_count => uint16(),
      peer_unidi_stream_count => uint16(),
      handshake_idle_timeout_ms => non_neg_integer(),
      quic_event_mask => uint32(),
      param_conn_disable_1rtt_encryption => boolean(),
      param_conn_local_address => string()}.
-type conn_shutdown_flag() :: 0 | 1.
-type connection_handle() :: reference().
-type connection_opts() :: proplists:proplist() | quicer_connection:opts().
-type execution_profile() ::
    quic_execution_profile_low_latency | quic_execution_profile_type_max_throughput |
    quic_execution_profile_type_scavenger | quic_execution_profile_type_realtime.
-type fpbuffer() :: #{next_offset := non_neg_integer(), buffer := quic_data_buffer()}.
-type global_handle() :: quic_global.
-type ifrag() :: {Index :: non_neg_integer(), quic_data()}.
-type listen_on() :: inet:port_number() | string().
-type listen_opts() :: listen_security_opts() | quic_settings().
Link to this type

listen_security_opts/0

View Source
-type listen_security_opts() ::
    #{alpn := [alpn()],
      cert := file:filename(),
      certfile := file:filename(),
      key := file:filename(),
      keyfile := file:filename(),
      verify => none | peer | verify_peer | verify_none,
      cacertfile => filelib:filename(),
      password => string(),
      sslkeylogfile => filelib:filename(),
      allow_insecure => boolean(),
      quic_registration => reg_handle(),
      conn_acceptors => non_neg_integer()}.
-type listener_handle() :: reference().
-type listener_opts() :: proplists:proplist() | quicer_listener:listener_opts().
-type optlevel() :: false | quic_global | quic_registration | quic_configuration | quic_tls.
Link to this type

optname_configuration/0

View Source
-type optname_configuration() :: param_configuration_settings | param_configuration_ticket_keys.
-type optname_conn() ::
    param_conn_quic_version | param_conn_local_address | param_conn_remote_address |
    param_conn_ideal_processor | param_conn_settings | param_conn_statistics |
    param_conn_statistics_plat | param_conn_share_udp_binding |
    param_conn_local_bidi_stream_count | param_conn_local_unidi_stream_count |
    param_conn_max_stream_ids | param_conn_close_reason_phrase |
    param_conn_stream_scheduling_scheme | param_conn_datagram_receive_enabled |
    param_conn_datagram_send_enabled | param_conn_disable_1rtt_encryption |
    param_conn_resumption_ticket | param_conn_peer_certificate_valid | param_conn_local_interface.
-type optname_global() ::
    param_global_retry_memory_percent | param_global_supported_versions |
    param_global_load_balacing_mode | param_global_perf_counters | param_global_settings |
    param_global_version.
-type optname_listener() ::
    param_listener_local_address | param_listener_stats | param_listener_cibir_id.
-type optname_reg() :: param_registration_cid_prefix.
-type optname_stream() ::
    active | controlling_process | param_stream_id | param_stream_0rtt_length |
    param_stream_ideal_send_buffer_size | param_stream_priority.
-type optname_tls() ::
    param_tls_schannel_context_attribute_w | param_tls_handshake_info | param_tls_negotiated_alpn.
-type quic_data() :: #quic_data{}.
-type quic_data_buffer() :: ordsets:ordset(ifrag()).
-type quic_handle_level() :: quic_tls | quic_configuration | false.
-type quic_settings() ::
    #{max_bytes_per_key => uint64(),
      handshake_idle_timeout_ms => uint64(),
      idle_timeout_ms => uint64(),
      tls_client_max_send_buffer => uint32(),
      tls_server_max_send_buffer => uint32(),
      stream_recv_window_default => uint32(),
      stream_recv_buffer_default => uint32(),
      conn_flow_control_window => uint32(),
      max_stateless_operations => uint32(),
      initial_window_packets => uint32(),
      send_idle_timeout_ms => uint32(),
      initial_rtt_ms => uint32(),
      max_ack_delay_ms => uint32(),
      disconnect_timeout_ms => uint32(),
      keep_alive_interval_ms => uint32(),
      peer_bidi_stream_count => uint16(),
      peer_unidi_stream_count => uint16(),
      retry_memory_limit => uint16(),
      load_balancing_mode => uint16(),
      max_operations_per_drain => uint8(),
      send_buffering_enabled => uint8(),
      pacing_enabled => uint8(),
      migration_enabled => uint8(),
      datagram_receive_enabled => uint8(),
      server_resumption_level => uint8(),
      minimum_mtu => uint16(),
      maximum_mtu => uint16(),
      mtu_discovery_search_complete_timeout_us => uint64(),
      mtu_discovery_missing_probe_count => uint8(),
      max_binding_stateless_operations => uint16(),
      stateless_operation_expiration_ms => uint16()}.
-type recv_data_props() :: #{absolute_offset := integer(), len := integer(), flags := integer()}.
-type reg_handle() :: reference().
-type send_flags() :: non_neg_integer().
-type stream_handle() :: reference().
-type stream_open_flags() :: 0 | 1 | 2.
-type stream_opts() ::
    #{active := boolean() | once | integer(),
      open_flag => stream_open_flags(),
      start_flag => stream_start_flags(),
      event_mask => uint32(),
      disable_fpbuffer => boolean()}.
Link to this type

stream_shutdown_flags/0

View Source
-type stream_shutdown_flags() :: 0 | 1 | 2 | 4 | 6 | 8.
-type stream_start_flags() :: 0 | 1 | 2 | 4 | 8.
-type uint8() :: 0..1 bsl 8 - 1.
-type uint16() :: 0..1 bsl 16 - 1.
-type uint32() :: 0..1 bsl 32 - 1.
-type uint64() :: 0..1 bsl 64 - 1.
-type user_opts() :: #{_ => _}.

Functions

-spec abi_version() -> quicer_nif:abi_version().
Return ABI version of the library.
-spec accept(listener_handle(), acceptor_opts()) -> {ok, connection_handle()} | {error, any()}.

Accept new Connection (Server)

Accept new connection from listener_handle().

Calling process becomes the owner of the connection.
Link to this function

accept(LSock, Opts, Timeout)

View Source
-spec accept(listener_handle(), acceptor_opts(), timeout()) ->
          {ok, connection_handle()} |
          {error, badarg | param_error | not_enough_mem | badpid} |
          {error, timeout}.
Accept new Connection (Server) with timeout

See also: accept/2.

Link to this function

accept_stream(Conn, Opts)

View Source
-spec accept_stream(connection_handle(), stream_opts()) ->
                 {ok, stream_handle()} |
                 {error, badarg | internal_error | bad_pid | owner_dead} |
                 {erro, timeout}.

Accept new stream on a existing connection with stream opts

Calling process become the owner of the new stream and it get monitored by NIF.

Once the Calling process is dead, closing stream will be triggered. (@TODO may not be default)
Link to this function

accept_stream(Conn, Opts, Timeout)

View Source
-spec accept_stream(connection_handle(), stream_opts(), timeout()) ->
                 {ok, stream_handle()} |
                 {error, badarg | internal_error | bad_pid | owner_dead} |
                 {erro, timeout}.

Accept new stream on a existing connection with stream opts with timeout

Calling process become the owner of the new stream and it get monitored by NIF.

Once the Calling process is dead, closing stream will be triggered.

See also: async_accept_stream/2.

Link to this function

async_accept(Listener, Opts)

View Source
-spec async_accept(listener_handle(), acceptor_opts()) ->
                {ok, listener_handle()} | {error, badarg | param_error | not_enough_mem | badpid}.
Link to this function

async_accept_stream(Conn, Opts)

View Source
-spec async_accept_stream(connection_handle(), proplists:proplist() | map()) ->
                       {ok, connection_handle()} | {error, any()}.

Accept new stream on a existing connection with stream opts

Calling process become the owner of the new stream and it get monitored by NIF.

Once the Calling process is dead, closing stream will be triggered.

Caller process should expect to receive
  {quic, new_stream, stream_handle(), new_stream_props()}

note, it returns

  {ok, connection_handle()}.
NOT
  {ok, stream_handle()}.

See also: async_accept_stream/2.

Link to this function

async_close_connection(Conn)

View Source
-spec async_close_connection(connection_handle()) -> ok.
Link to this function

async_close_connection(Conn, Flags, ErrorCode)

View Source
-spec async_close_connection(connection_handle(), conn_shutdown_flag(), app_errno()) -> ok.
Async variant of close_connection/4

See also: async_close_connection/3.

Link to this function

async_close_stream(Stream)

View Source
-spec async_close_stream(stream_handle()) -> ok | {error, badarg}.
async variant of close_stream/1, prefer to use async_shutdown_stream/4

See also: async_shutdown_stream/4, close_stream/4.

Link to this function

async_connect(Host, Port, Opts)

View Source
-spec async_connect(inet:hostname() | inet:ip_address(), inet:port_number(), conn_opts()) ->
                 {ok, connection_handle()} |
                 {error, conn_open_error | config_error | conn_start_error}.

Initiate New Connection (Client)

Async variant of connect/4

See also: connect/4.

Link to this function

async_csend(Conn, IoData, Opts, SendFlags)

View Source
-spec async_csend(connection_handle(), iodata(), stream_opts(), send_flags()) ->
               {ok, stream_handle()} |
               {error, any()} |
               {error, stm_open_error, atom_reason()} |
               {error, stream_send_error, atom_reason()}.
Send data over a new local stream in the connection, return new stream handle if success.
-spec async_handshake(connection_handle()) -> ok | {error, any()}.
Complete TLS handshake after accepted a Connection. Caller should expect to receive
  {quic, connected, connection_handle()}

See also: handshake/2.

Link to this function

async_send(Stream, Data)

View Source
-spec async_send(stream_handle(), iodata()) ->
              {ok, BytesSent :: pos_integer()} |
              {error, badarg | not_enough_mem | closed} |
              {error, stream_send_error, atom_reason()}.
async variant of send/2 Caller should NOT expect to receive
     {quic, send_complete, Stream, send_complete_flag()}
note, check send_complete_flag() to ensure it is delivered or not.
Link to this function

async_send(Stream, Data, Flag)

View Source
-spec async_send(stream_handle(), iodata(), non_neg_integer()) ->
              {ok, BytesSent :: pos_integer()} |
              {error, badarg | not_enough_mem | closed} |
              {error, stream_send_error, atom_reason()}.
async variant of send/3 If QUICER_SEND_FLAG_SYNC is set , the caller should expect to receive {quic, send_complete, Stream, send_complete_flag()} note, check send_complete_flag() to ensure it is delivered or not.
Link to this function

async_shutdown_connection(Conn, Flags, ErrorCode)

View Source
-spec async_shutdown_connection(connection_handle(), conn_shutdown_flag(), app_errno()) ->
                             ok | {error, badarg | closed}.
Async starts the shutdown process and caller should expect for connection down message {quic, close, Conn}
Link to this function

async_shutdown_stream(Stream)

View Source
-spec async_shutdown_stream(stream_handle()) -> ok | {error, badarg | atom_reason()}.
async variant of shutdown_stream/2

See also: async_shutdown_stream/3.

Link to this function

async_shutdown_stream(Stream, Flags, Reason)

View Source
-spec async_shutdown_stream(stream_handle(), stream_shutdown_flags(), app_errno()) ->
                         ok | {error, badarg}.
async variant of shutdown_stream/4 Caller should expect to receive
     {quic, stream_closed, Stream, Flags}
-spec close_connection(connection_handle()) -> ok | {error, badarg}.
Link to this function

close_connection(Conn, Flags, ErrorCode)

View Source
-spec close_connection(connection_handle(), conn_shutdown_flag(), app_errno()) ->
                    ok | {error, badarg | timeout}.
Close connection with flag specified and application reason code.

See also: shutdown_connection/3.

Link to this function

close_connection(Conn, Flags, ErrorCode, Timeout)

View Source
-spec close_connection(connection_handle(), conn_shutdown_flag(), app_errno(), timeout()) ->
                    ok | {error, badarg | timeout}.
Close connection with flag specified and application reason code with timeout

See also: shutdown_connection/4.

-spec close_lib() -> ok.

Close library.

This is reserved for upgrade support

Danger! Do not use it!
Link to this function

close_listener(Listener)

View Source
-spec close_listener(listener_handle()) -> ok | {error, badarg | closed | timeout}.
close listener with listener handle
Link to this function

close_listener(Listener, Timeout)

View Source
-spec close_listener(listener_handle(), timer:time()) -> ok | {error, badarg | closed | timeout}.
Link to this function

close_registration(Handle)

View Source
-spec close_registration(Handle) -> quicer_nif:close_registration(Handle).
close a registration.
-spec close_stream(stream_handle()) -> ok | {error, badarg | timeout}.
Normal shutdown stream with infinity timeout.

See also: close_stream/2.

Link to this function

close_stream(Stream, Timeout)

View Source
-spec close_stream(stream_handle(), timeout()) -> ok | {error, badarg | timeout}.
Normal shutdown (App errno=0) Stream gracefully with timeout.

See also: close_stream/4.

Link to this function

close_stream(Stream, Flags, ErrorCode, Timeout)

View Source
-spec close_stream(stream_handle(), stream_shutdown_flags(), app_errno(), timeout()) ->
                ok | {error, badarg | timeout}.
Another name of shutdown stream for migration from tcp/ssl.

See also: close_stream/1, shutdown_stream/4.

Link to this function

connect(Host, Port, Opts, Timeout)

View Source
-spec connect(inet:hostname() | inet:ip_address(), inet:port_number(), conn_opts(), timeout()) ->
           {ok, connection_handle()} |
           {error, conn_open_error | config_error | conn_start_error} |
           {error, timeout} |
           {error, nst_not_found}.

Initiate New Connection (Client)

Initiate new connection to remote endpoint with connection opts specified.

See also: async_connect/3.

Link to this function

controlling_process(Handle, Pid)

View Source
-spec controlling_process(connection_handle() | stream_handle(), pid()) ->
                       ok | {error, closed | badarg | owner_dead | not_owner}.
set controlling process for Connection/Stream. mimic ssl:controlling_process/2

See also: wait_for_handoff/2.

Link to this function

defrag_fpbuffer(Offset, Buffer)

View Source
-spec defrag_fpbuffer(Offset :: non_neg_integer(), quic_data_buffer()) ->
                   {NewOffset :: non_neg_integer(),
                    NewBuffer :: quic_data_buffer(),
                    Res :: [quic_data()]}.
Pop out continuous data from the buffer start from the offset.
-spec get_conn_owner(C) -> quicer_nif:get_conn_owner(C).
-spec get_conn_rid(connection_handle()) -> {ok, non_neg_integer()} | {error, any()}.
-spec get_connections() -> quicer_nif:get_connections().
Get a list connections under global registration
-spec get_connections(Reg | global) -> quicer_nif:get_connections(Reg).
Get a list of connections under registration handle
-spec get_listener_owner(L) -> quicer_nif:get_listener_owner(L).
-spec get_listeners() -> quicer_nif:get_listeners().
Get a list listeners under global registration
-spec get_listeners(Reg | global) -> quicer_nif:get_listeners(Reg).
Get a list of listeners under registration handle
Link to this function

get_registration_name(Handle)

View Source
-spec get_registration_name(Handle) -> quicer_nif:get_registration_name(Handle).
get registration name
-spec get_stream_id(Stream :: stream_handle()) -> {ok, integer()} | {error, any()} | not_found.
get stream id with stream handle
-spec get_stream_owner(S) -> quicer_nif:get_stream_owner(S).
-spec get_stream_rid(stream_handle()) -> {ok, non_neg_integer()} | {error, any()}.
-spec getopt(Handle :: handle(), optname()) -> {ok, OptVal :: any()} | {error, any() | not_found}.
Get connection/stream/listener opts mimic ssl:getopts/2
Link to this function

getopt(Handle, Opt, Optlevel)

View Source
-spec getopt(handle(), optname(), optlevel()) ->
          not_found |
          {ok, [any()]} |
          {error, badarg | param_error | internal_error | not_enough_mem} |
          {error, atom_reason()}.
Get connection/stream/listener opts mimic ssl:getopt/2
-spec getstat(connection_handle(), [inet:stat_option()]) -> {ok, list()} | {error, any()}.
get connection state mimic ssl:getstat/2
Link to this function

handoff_stream(Stream, NewOwner)

View Source
-spec handoff_stream(stream_handle(), pid()) -> ok | {error, any()}.
handoff_stream without post handoff data. see handoff_stream/3
Link to this function

handoff_stream(Stream, NewOwner, HandoffData)

View Source
-spec handoff_stream(stream_handle(), pid(), term()) -> ok | {error, any()}.
Used by Old stream owner to handoff to the new stream owner. 1. The Stream will be put into passive mode. 2. Stream messages in the current owners process messages queue will be forwarded to the New Owner's mailbox in the same recv order. 3. Set the control process of the stream to the new owner. 4. A signal msg {handoff_done, Stream, PostHandoff} will be sent to the new owner. The new owner should block for this message before handle any stream data to ensure the ordering. 5. Revert stream active mode whatever handoff fail or success. also @see wait_for_handoff/2
-spec handshake(connection_handle()) -> {ok, connection_handle()} | {error, any()}.
Complete TLS handshake after accepted a Connection with 5s timeout (Server)

See also: accept/3, handshake/2.

Link to this function

handshake(Conn, Timeout)

View Source
-spec handshake(connection_handle(), timeout()) -> {ok, connection_handle()} | {error, any()}.
Complete TLS handshake after accepted a Connection

See also: async_handshake/1, handshake/2.

Link to this function

is_unidirectional(Flags)

View Source
-spec is_unidirectional(stream_open_flags()) -> boolean().
Return true if stream open flags has unidirectional flag set
-spec listen(listen_on(), listen_opts()) ->
          {ok, listener_handle()} |
          {error, quic_tls} |
          {error, cacertfile} |
          {error, quic_registration} |
          {error, badarg} |
          {error, listener_open_error, atom_reason()} |
          {error, listener_start_error, atom_reason()}.

Start listen on Port or "HOST:PORT".

listener_handle() is used for accepting new connection. notes,

1. Port binding is done in NIF context, thus you cannot see it from inet:i().

2. ListenOn can either be integer() for Port or be String for HOST:PORT

3. There is no address binding even HOST is specified.
-spec listener(quicer_listener:listener_name() |
         {quicer_listener:listener_name(), quicer_listener:listen_on()}) ->
            {ok, pid()} | {error, not_found}.
List listener with app name
-spec listeners() -> [{{quicer_listener:listener_name(), quicer_listener:listen_on()}, pid()}].
list all listeners
Link to this function

merge_quic_datalist(QuicDataList)

View Source
-spec merge_quic_datalist([quic_data()]) -> {iolist(), Size :: non_neg_integer(), Flag :: integer()}.
Link to this function

negotiated_protocol(Conn)

View Source
-spec negotiated_protocol(Conn :: connection_handle()) ->
                       {ok, Protocol :: binary()} | {error, Reason :: any()}.
Returns the protocol negotiated through ALPN or NPN extensions.
-spec new_fpbuffer() -> fpbuffer().
Link to this function

new_fpbuffer(StartOffset)

View Source
Link to this function

new_registration(Name, Profile)

View Source
-spec new_registration(Name, Profile) -> quicer_nif:new_registration(Name, Profile).
Create a new registration.
-spec open_connection() -> {ok, connection_handle()} | {error, atom_reason()}.
-spec open_lib() -> {ok, true} | {ok, false} | {ok, debug} | {error, open_failed, atom_reason()}.

Quicer library must be opened before any use.

This is called automatically while quicer application is started
-spec peercert(connection_handle() | stream_handle()) ->
            {ok, Cert :: public_key:der_encoded()} | {error, any()}.
Peer Cert in DER-encoded binary mimic ssl:peername/1
-spec peername(connection_handle() | stream_handle()) ->
            {ok, {inet:ip_address(), inet:port_number()}} | {error, any()}.
Peer name mimic ssl:peername/1
-spec perf_counters() -> {ok, [{atom(), integer()}]} | {error, any()}.
get QUIC stack performance counters
-spec quic_data({quic, binary(), stream_handle(), recv_data_props()}) -> quic_data().
Convert quic data event to quic_data for fpbuffer
-spec recv(stream_handle(), Count :: non_neg_integer()) -> {ok, binary()} | {error, any()}.

Recv Data (Passive mode) Passive recv data from stream.

If Len = 0, return all data in recv buffer if it is not empty. if buffer is empty, blocking for a Quic msg from stack to arrive and return all data in that msg.

If Len > 0, desired bytes will be returned, other data would be left in recv buffer.

Suggested to use Len=0 if caller want to buffer or reassemble the data on its own.

note, the requested Len cannot exceed the 'stream_recv_window_default' specified in connection opts otherwise the function will never return
-spec reg_close() -> ok.
close Registraion. Reserved for future upgrade, don't use it.

See also: reg_open/1.

GRegistraion should be opened before calling traffic APIs.

This is called automatically when quicer application starts with app env: profile

See also: reg_close/0, reg_open/1.

-spec reg_open(execution_profile()) -> ok | {error, badarg}.

Registraion should be opened before calling traffic APIs. Registraion creates application context, worker threads shared for all the connections

Currently only support one application.

See also: reg_close/0, reg_open/1.

-spec send(stream_handle(), iodata()) ->
        {ok, BytesSent :: pos_integer()} |
        {error, cancelled} |
        {error, badarg | not_enough_mem | closed} |
        {error, stream_send_error, atom_reason()}.
Send binary data over stream, blocking until send request is handled by the transport worker. either succeeded or cancelled
Link to this function

send(Stream, Data, Flag)

View Source
-spec send(stream_handle(), iodata(), non_neg_integer()) ->
        {ok, BytesSent :: pos_integer()} |
        {error, cancelled} |
        {error, badarg | not_enough_mem | closed} |
        {error, stream_send_error, atom_reason()}.
Send binary data over stream with send flags either succeeded or cancelled
-spec send_dgram(connection_handle(), binary()) ->
              {ok, BytesSent :: pos_integer()} |
              {error, badarg | not_enough_mem | closed} |
              {error, dgram_send_error, atom_reason()}.

Sending Unreliable Datagram

ref: https://datatracker.ietf.org/doc/html/draft-ietf-quic-datagram

See also: send/2.

Link to this function

setopt(Handle, Opt, Value)

View Source
-spec setopt(handle(), optname(), any()) ->
          ok |
          {error, badarg | param_error | internal_error | not_enough_mem} |
          {error, atom_reason()}.
Set connection/stream/listener opts mimic ssl:setopt/2
Link to this function

setopt(Handle, Opt, Value, Level)

View Source
-spec setopt(handle(), optname(), any(), quic_handle_level()) ->
          ok |
          {error, badarg | param_error | internal_error | not_enough_mem} |
          {error, atom_reason()}.
Link to this function

shutdown_connection(Conn)

View Source
-spec shutdown_connection(connection_handle()) -> ok | {error, timeout | closed}.
Starts the shutdown process on a connection and block until it is finished.

See also: shutdown_connection/4.

Link to this function

shutdown_connection(Conn, Timeout)

View Source
-spec shutdown_connection(connection_handle(), timeout()) -> ok | {error, timeout | badarg}.
Starts the shutdown process on a connection and block until it is finished. but with a timeout

See also: shutdown_connection/4.

Link to this function

shutdown_connection(Conn, Flags, ErrorCode)

View Source
-spec shutdown_connection(connection_handle(), conn_shutdown_flag(), app_errno()) ->
                       ok | {error, timeout | badarg}.
Starts the shutdown process on a connection with shutdown flag and applications error with 5s timeout
Link to this function

shutdown_connection(Conn, Flags, ErrorCode, Timeout)

View Source
-spec shutdown_connection(connection_handle(), conn_shutdown_flag(), app_errno(), timeout()) ->
                       ok | {error, timeout | badarg}.
Starts the shutdown process on a connection with shutdown flag and applications error with timeout

See also: shutdown_connection/1, shutdown_connection/2, shutdown_connection/3.

Link to this function

shutdown_registration(Handle)

View Source
-spec shutdown_registration(Handle) -> quicer_nif:shutdown_registration(Handle).
Shutdown a registration.
Link to this function

shutdown_registration(Handle, IsSilent, ErrCode)

View Source
-spec shutdown_registration(Handle, IsSilent, ErrCode) ->
                         quicer_nif:shutdown_registration(Handle, IsSilent, ErrCode).
Shutdown a registration with error code and silent flag.
-spec shutdown_stream(stream_handle()) -> ok | {error, badarg}.
Shutdown stream gracefully, with infinity timeout

See also: shutdown_stream/1.

Link to this function

shutdown_stream(Stream, Timeout)

View Source
-spec shutdown_stream(stream_handle(), timeout()) -> ok | {error, badarg} | {error, timeout}.

Shutdown stream gracefully, with app_errno 0

returns when both endpoints closed the stream

See also: shutdown_stream/4.

Link to this function

shutdown_stream(Stream, Flags, ErrorCode, Timeout)

View Source
-spec shutdown_stream(stream_handle(), stream_shutdown_flags(), app_errno(), timeout()) ->
                   ok | {error, badarg} | {error, timeout}.

Start shutdown Stream process with flags and application specified error code.

returns when stream closing is confirmed in the stack (Blocking).

Flags could be used to control the behavior like half-close.

See also: async_shutdown_stream/4.

-spec sockname(listener_handle() | connection_handle() | stream_handle()) ->
            {ok, {inet:ip_address(), inet:port_number()}} | {error, any()}.
Get socket name mimic ssl:sockname/1
Link to this function

spawn_listener(Appname, Port, Options)

View Source
-spec spawn_listener(Appname :: atom() | listener_handle(),
               listen_on(),
               {listener_opts(), connection_opts(), stream_opts() | user_opts()}) ->
                  {ok, pid()} | {error, any()}.
start a listener process under supervisor tree
Link to this function

start_listener(Listener, Port, Options)

View Source
-spec start_listener(listener_handle(), listen_on(), listen_opts()) -> {ok, pid()} | {error, any()}.
Start a stopped listener with listener handle.
Link to this function

start_stream(Conn, Opts)

View Source
-spec start_stream(connection_handle(), stream_opts()) ->
                {ok, stream_handle()} |
                {error, badarg | internal_error | bad_pid | owner_dead} |
                {error, stream_open_error, atom_reason()} |
                {error, stream_start_error, atom_reason()}.

Start new stream in connection, return new stream handle.

Calling process becomes the owner of the stream.

Both client and server could start the stream.
-spec stop_listener(listener_handle()) -> ok.
Stop a started listener which could be closed or restarted later.
Link to this function

terminate_listener(AppName)

View Source
-spec terminate_listener(atom() | listener_handle()) -> ok.
terminate a listener process under supervisor tree
Link to this function

update_fpbuffer(Quic_data, This)

View Source
-spec update_fpbuffer(quic_data(), fpbuffer()) -> {[quic_data()], NewBuff :: fpbuffer()}.
update fpbuffer and return *next* continuous data.
Link to this function

wait_for_handoff(From, Stream)

View Source
-spec wait_for_handoff(From :: pid(), stream_handle()) -> {error, owner_down} | {ok, PostInfo :: term()}.
Used by new stream owner to wait for stream handoff complete. Use this for handoff the orphan stream *only*.

See also: controlling_process/2, handoff_stream/3.