...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Write a message to the stream.
template< class ConstBufferSequence> std::size_t write( ConstBufferSequence const& buffers, error_code& ec);
This function is used to synchronously write a message to the stream. The call blocks until one of the following conditions is met:
This operation is implemented in terms of one or more calls to the next
layer's write_some
function.
The current setting of the websocket::stream::binary
option controls whether
the message opcode is set to text or binary. If the websocket::stream::auto_fragment
option is set,
the message will be split into one or more frames as necessary. The actual
payload contents sent may be transformed as per the WebSocket protocol
settings.
Name |
Description |
---|---|
|
The buffers containing the entire message payload. The implementation will make copies of this object as needed, but ownership of the underlying memory is not transferred. The caller is responsible for ensuring that the memory locations pointed to by buffers remains valid until the completion handler is called. |
The number of bytes written from the buffers. If an error occurred, this will be less than the sum of the buffer sizes.
Name |
Description |
---|---|
|
Set to indicate what error occurred, if any. |
Type |
Thrown On |
---|---|
|
Thrown on failure. |
This function always sends an entire message. To send a message in fragments,
use websocket::stream::write_some
.