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 the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext
websocket::stream::accept_ex (5 of 6 overloads)

Respond to a WebSocket HTTP Upgrade request.

Synopsis
template<
    class Body,
    class Allocator,
    class ResponseDecorator>
void
accept_ex(
    http::request< Body, http::basic_fields< Allocator >> const& req,
    ResponseDecorator const& decorator);
Description

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.

Parameters

Name

Description

req

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

decorator

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
);
Exceptions

Type

Thrown On

system_error

Thrown on failure.


PrevUpHomeNext