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::async_write_some

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

Synopsis
template<
    class ConstBufferSequence,
    class WriteHandler>
void-or-deduced
async_write_some(
    bool fin,
    ConstBufferSequence const& buffers,
    WriteHandler&& handler);
Description

This function is used to asynchronously write a message frame on the stream. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:

This operation is implemented in terms of one or more calls to the next layer's async_write_some functions, and is known as a composed operation. The actual payload sent may be transformed as per the WebSocket protocol settings. The program must ensure that the stream performs no other write operations (such as websocket::stream::async_write, websocket::stream::async_write_some, or websocket::stream::async_close).

If this is the beginning of a new message, the message opcode will be set to text or binary as per the current setting of the websocket::stream::binary option. The actual payload sent may be transformed as per the WebSocket protocol settings.

Parameters

Name

Description

fin

true if this is the last part of the message.

buffers

A object meeting the requirements of ConstBufferSequence which holds the payload data before any masking or compression. Although the buffers object may be copied as necessary, ownership of the underlying buffers is retained by the caller, which must guarantee that they remain valid until the handler is called.

handler

The handler to be called when the write completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be:

 void handler(
    error_code const& ec,           // Result of operation
    std::size_t bytes_transferred   // Number of bytes written from the
                                    // buffers. If an error occurred,
                                    // this will be less than the sum
                                    // of the buffer sizes.
);

PrevUpHomeNext