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 to view this page for the latest version.
PrevUpHomeNext
websocket::stream::accept (5 of 6 overloads)

Respond to a WebSocket HTTP Upgrade request.

Synopsis
template<
    class Body,
    class Allocator>
void
accept(
    http::request< Body, http::basic_fields< Allocator >> const& req);
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.

Exceptions

Type

Thrown On

system_error

Thrown on failure.


PrevUpHomeNext