Here is a way to set subprotocol for Websocket in Boost:
if the Boost version >= 1.7.0, then: Click here for more detail
stream<tcp_stream> ws(ioc);
ws.set_option(stream_base::decorator(
[](request_type& req)
{
// Set the client field on the request
req.set(boost::beast::http::field::sec_websocket_protocol, "protoo");
req.set(boost::beast::http::field::sec_websocket_version, "13");
req.set(boost::beast::http::field::sec_websocket_extensions,
"xxx");
}));
else: Click here for more detail
stream<tcp_stream> ws(ioc);
ws.handshake_ex("ws://127.0.0.1:5005", "/",
[](request_type& req)
{
req.insert(boost::beast::http::field::sec_websocket_protocol, "protoo");
req.insert(boost::beast::http::field::sec_websocket_version, "13");
req.insert(boost::beast::http::field::sec_websocket_extensions,
"xxx");
});