...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Start an asynchronous operation to send an upgrade request and receive the response.
template< class RequestDecorator, class HandshakeHandler> DEDUCED async_handshake_ex( response_type& res, string_view host, string_view target, RequestDecorator const& decorator, HandshakeHandler&& handler);
This function is used to asynchronously send the HTTP WebSocket upgrade request and receive the HTTP WebSocket Upgrade response. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next
layer's async_read_some
and async_write_some
functions, and is known as a composed operation.
The program must ensure that the stream performs no other operations
until this operation completes.
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 caller must ensure this object is valid for at least until the completion handler is invoked. |
|
The name of the remote host, required by the HTTP protocol. Copies may be made as needed. |
|
The Request Target, which may not be empty, required by the HTTP protocol. Copies of this parameter may be made as needed. |
|
A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: void decorator( request_type& req ); |
|
Invoked when the operation completes. The handler may be moved or copied as needed. The equivalent function signature of the handler must be: void handler( error_code const& ec // Result of operation );
Regardless of whether the asynchronous operation completes
immediately or not, the handler will not be invoked from within
this function. Invocation of the handler will be performed
in a manner equivalent to using |