quicer_connection behaviour (quicer v0.4.3)
View SourceQuic Connection Behavior
Best practice for 1. server side connection acceptor
1. server side connection initiator
Summary
Functions
get connection handle from quic connection process
start acceptor with shared Listener confs
Spawn Client connection or Start connection acceptor at server side
Types
-type cb_ret() :: quicer_lib:cb_ret().
-type cb_state() :: quicer_lib:cb_state().
-type conf_handle() :: reference().
-type conn_opts() :: #{alpn := [string()], conn_callback => module(), custom_verify => boolean(), handle => connection_handle(), nst => binary(), handshake_idle_timeout_ms => non_neg_integer(), quic_event_mask => uint32(), disable_1rtt_encryption => boolean(), local_address => string(), local_bidi_stream_count => uint16(), local_peer_unidi_stream_count => uint16(), cert => file:filename(), certfile => file:filename(), key => file:filename(), keyfile => file:filename(), password => string(), verify => none | peer | verify_peer | verify_none, cacertfile => file:filename(), sslkeylogfile => file:filename(), 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(), congestion_control_algorithm => uint16(), 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(), dynamic() => dynamic()}.
-type connection_handle() :: reference().
-type csend_flags() :: 0 | 1 | 2 | 4 | 8 | 16.
-type global_handle() :: quic_global.
-type handle() :: global_handle() | listener_handle() | connection_handle() | stream_handle() | conf_handle() | reg_handle().
-type hostname() :: string().
-type listener_handle() :: reference().
-type reg_handle() :: reference().
-type send_flags() :: csend_flags() | 4096.
-type state() :: #{listener := listener_handle(), conn := connection_handle(), callback := atom(), callback_state := term(), sup := undefined | pid(), conn_opts := map(), stream_opts := map(), is_resumed := boolean()}.
-type stream_handle() :: reference().
-type stream_open_flags() :: 0 | 1 | 2.
-type stream_opts() :: #{active := active_n(), open_flag => stream_open_flags(), start_flag => stream_start_flags(), event_mask => uint32(), disable_fpbuffer => boolean(), stream_id => uint62(), priority => uint16(), ideal_send_buffer_size => uint64(), '0rtt_length' => uint64(), dynamic() => dynamic()}.
-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 uint62() :: 0..1 bsl 62 - 1.
-type uint64() :: 0..1 bsl 64 - 1.
Callbacks
-callback closed(connection_handle(), conn_closed_props(), cb_state()) -> cb_ret().
-callback connected(connection_handle(), connected_props(), cb_state()) -> cb_ret().
-callback dgram_recv(connection_handle(), DataBin :: binary(), Flags :: non_neg_integer(), cb_state()) -> cb_ret().
-callback dgram_state_changed(connection_handle(), dgram_state(), cb_state()) -> cb_ret().
-callback handle_call(Req :: term(), From :: gen_server:from(), cb_state()) -> cb_ret().
-callback local_address_changed(connection_handle(), quicer_addr(), cb_state()) -> cb_ret().
-callback new_conn(connection_handle(), new_conn_props(), cb_state()) -> cb_ret().
-callback new_stream(stream_handle(), new_stream_props(), cb_state()) -> cb_ret().
-callback nst_received(connection_handle(), TicketBin :: binary(), cb_state()) -> cb_ret().
-callback peer_address_changed(connection_handle(), quicer_addr(), cb_state()) -> cb_ret().
-callback peer_cert_received(connection_handle(), cert_and_chain(), cb_state()) -> cb_ret().
-callback peer_needs_streams(connection_handle(), unidi_streams | bidi_streams, cb_state()) -> cb_ret().
-callback resumed(connection_handle(), SessionData :: binary() | false, cb_state()) -> cb_ret().
-callback shutdown(connection_handle(), error_code(), cb_state()) -> cb_ret().
-callback streams_available(connection_handle(), {BidirStreams :: non_neg_integer(), UnidirStreams :: non_neg_integer()}, cb_state()) -> cb_ret().
-callback transport_shutdown(connection_handle(), transport_shutdown_props(), cb_state()) -> cb_ret().
Functions
-spec get_handle(pid()) -> undefined | connection_handle().
get connection handle from quic connection process
-spec start_acceptor(listener_handle(), ets:tid(), pid()) -> {ok, pid()} | {error, any()}.
start acceptor with shared Listener confs
-spec start_link(atom(), {hostname(), inet:port_number()}, {conn_opts(), stream_opts()}) -> gen_server:start_ret().
Spawn Client connection or Start connection acceptor at server side
-spec stream_send(ConnPid :: pid(), Callback :: atom(), Data :: iodata(), SendFlag :: send_flags(), StreamOpts :: stream_opts(), timeout()) -> ok | {error, any()}.