boost::corosio::tls_context::set_alpn

Set the ALPN protocol list.

Synopsis

std::error_code
set_alpn(std::initializer_list<std::string_view> protocols);

Description

Configures Application‐Layer Protocol Negotiation (ALPN) for the connection. ALPN is used to negotiate which application protocol to use over the TLS connection (e.g., "h2" for HTTP/2, "http/1.1" for HTTP/1.1).

The protocols are tried in preference order (first = highest).

Example

// Prefer HTTP/2, fall back to HTTP/1.1
ctx.set_alpn( { "h2", "http/1.1" } );

Return Value

Success, or an error if ALPN configuration fails.

Parameters

Name Description

protocols

Ordered list of protocol identifiers.

Created with MrDocs