ALPN or Application Layer Protocol Name is a TLS extension that includes the protocol negotiation within the exchange of hello messages. ALPN is able to negotiate which protocol should be handled over a secure connection in a way that is more efficient and avoids additional round trips. The ever-growing in popularity HTTP/2 protocol, makes use of ALPN to further decrease website load times and encrypt connections faster.
According to the RFC 7301 specification, with ALPN the client will send a list of supported application protocols to the server as part of the TLS ClientHello message. The server then selects a protocol and sends back that protocol in its ServerHello message. The application protocol negotiation can therefore be accomplished over one single round trip within the TLS handshake. This method also allows the server to associate a different certificate with each application protocol.
From sgcWebSockets 4.3.2, if you compile sgcWebSockets with our custom Indy library you can make use of ALPN protocol. Indy by default doesn't implements this protocol.
Client
Create a new websocket client which requires "h2" for ALPN, check after connects which protocol has server accepted.
Server
Create a new websocket client which checks if client supports "h2" ALPN connections.