...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Perform the WebSocket handshake asynchronously in the server role.
template< class Body, class Allocator, class AcceptHandler> DEDUCED async_accept( http::request< Body, http::basic_fields< Allocator >> const& req, AcceptHandler&& handler);
This initiating function is used to asynchronously begin performing the WebSocket handshake, required before messages can be sent and received. During the handshake, the client sends the Websocket Upgrade HTTP request, and the server replies with an HTTP response indicating the result of the handshake. This call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
The algorithm, known as a composed asynchronous operation,
is implemented in terms of calls to the next layer's async_read_some
and async_write_some
functions. No other operation may be performed on the stream until this
operation completes. If a valid upgrade request is received, an HTTP
response with a status-code
of http::switching_protocols
is sent
to the peer, otherwise a non-successful error is associated with the
operation.
Name |
Description |
---|---|
|
An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
|
The completion handler to invoke when the operation completes. The implementation takes ownership of the handler by performing a decay-copy. 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 |