Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
websocket::stream::accept_ex (6 of 6 overloads)

Respond to a WebSocket HTTP Upgrade request.

    class Body,
    class Allocator,
    class ResponseDecorator>
    http::request< Body, http::basic_fields< Allocator >> const& req,
    ResponseDecorator const& decorator,
    error_code& ec);

This function is used to synchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade. 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.

If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.





An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads.


A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature:

 void decorator(
    response_type& res


Set to indicate what error occurred, if any.