Beast Logo



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

    class ConstBufferSequence,
    class WriteHandler>
    bool fin,
    ConstBufferSequence const& buffers,
    WriteHandler&& handler);

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 stream::async_write, stream::async_write_frame, or 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 message_type option. The actual payload sent may be transformed as per the WebSocket protocol settings.



A bool indicating whether or not the frame is the last frame in the corresponding WebSockets message.


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.


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& error // result of operation