Beast Logo

PrevUpHomeNext

websocket::stream

Provides message-oriented functionality using WebSocket.

template<
    class NextLayer>
class stream :
    public stream_base
Types

Name

Description

lowest_layer_type

The type of the lowest layer.

next_layer_type

The type of the next layer.

Member Functions

Name

Description

accept

Read and respond to a WebSocket HTTP Upgrade request.

Respond to a WebSocket HTTP Upgrade request.

async_accept

Start reading and responding to a WebSocket HTTP Upgrade request.

Start responding to a WebSocket HTTP Upgrade request.

async_close

Start an asynchronous operation to send a WebSocket close frame.

async_handshake

Start an asynchronous operation to send an upgrade request and receive the response.

async_ping

Start an asynchronous operation to send a WebSocket ping frame.

async_pong

Start an asynchronous operation to send a WebSocket pong frame.

async_read

Start an asynchronous operation to read a message from the stream.

async_read_frame

Start an asynchronous operation to read a message frame from the stream.

async_write

Start an asynchronous operation to write a message to the stream.

async_write_frame

Start an asynchronous operation to send a message frame on the stream.

close

Send a WebSocket close frame.

get_io_service

Get the io_service associated with the stream.

get_option

Get the permessage-deflate extension options.

handshake

Send a HTTP WebSocket Upgrade request and receive the response.

lowest_layer

Get a reference to the lowest layer.

next_layer

Get a reference to the next layer.

operator=

Move assignment.

ping

Send a WebSocket ping frame.

pong

Send a WebSocket pong frame.

read

Read a message from the stream.

read_frame

Read a message frame from the stream.

reason

Returns the close reason received from the peer.

set_option

Set options on the stream.

Set the automatic fragment size option.

Set the decorator used for HTTP messages.

Set the keep-alive option.

Set the outgoing message type.

Set the permessage-deflate extension options.

Set the ping callback.

Set the read buffer size.

Set the maximum incoming message size allowed.

Set the size of the write buffer.

stream

Move-construct a stream.

Construct a WebSocket stream.

write

Write a message to the stream.

write_frame

Write partial message data on the stream.

~stream

Destructor.

The websocket::stream class template provides asynchronous and blocking message-oriented functionality necessary for clients and servers to utilize the WebSocket protocol.

Thread Safety

Distinct objects: Safe.

Shared objects: Unsafe. The application must ensure that all asynchronous operations are performed within the same implicit or explicit strand.

Example

To use the websocket::stream template with an ip::tcp::socket, you would write:

websocket::stream<ip::tcp::socket> ws(io_service);

Alternatively, you can write:

ip::tcp::socket sock(io_service);
websocket::stream<ip::tcp::socket&> ws(sock);

NextLayer

The type representing the next layer, to which data will be read and written during operations. For synchronous operations, the type must support the SyncStream concept. For asynchronous operations, the type must support the AsyncStream concept.

Remarks

A stream object must not be moved or destroyed while there are pending asynchronous operations associated with it.

Concepts

AsyncStream, Decorator, DynamicBuffer, SyncStream

Requirements

Header: beast/websocket/stream.hpp

Convenience header: beast/websocket.hpp


PrevUpHomeNext