Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This is an older version of Boost and was released in 2018. The current version is 1.92.0.
Send an HTTP WebSocket Upgrade request and receive the response.
void handshake( response_type& res, string_view host, string_view target);
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next
layer's read_some and
write_some functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
|
Name |
Description |
|---|---|
|
|
The HTTP Upgrade response returned by the remote endpoint. |
|
|
The name of the remote host, required by the HTTP protocol. |
|
|
The Request Target, which may not be empty, required by the HTTP protocol. |
|
Type |
Thrown On |
|---|---|
|
|
Thrown on failure. |
websocket::stream<ip::tcp::socket> ws{io_context}; ... try { response_type res; ws.handshake(res, "localhost", "/"); } catch(...) { // An error occurred. }