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::close (2 of 2 overloads)

Send a WebSocket close frame.

Synopsis
void
close(
    close_reason const& cr,
    error_code& ec);
Description

This function is used to synchronously send a close frame on the stream. The call blocks until one of the following is true:

This function is implemented in terms of one or more calls to the next layer's write_some functions.

If the close reason specifies a close code other than beast::websocket::close_code::none, the close frame is sent with the close code and optional reason string. Otherwise, the close frame is sent with no payload.

Callers should not attempt to write WebSocket data after initiating the close. Instead, callers should continue reading until an error occurs. A read returning websocket::closed indicates a successful connection closure.

Parameters

Name

Description

cr

The reason for the close.

ec

Set to indicate what error occurred, if any.


PrevUpHomeNext