en	Messages

en	Once a websocket session is established, messages can be sent unsolicited by either peer at any time. A message is made up of one or more ['messages frames]. Each frame is prefixed with the size of the payload in bytes, followed by the data. A frame also contains a flag (called 'fin') indicating whether or not it is the last frame of the message. When a message is made up from only one frame, it is possible to know immediately what the size of the message will be. Otherwise, the total size of the message can only be determined once the last frame is received.

en	The boundaries between frames of a multi-frame message are not not considered part of the message. Intermediaries such as proxies which forward the websocket traffic are free to "reframe" (split frames and combine them) the message in arbitrary ways. These intermediaries include Beast, which can reframe messages automatically in some cases depending on the options set on the stream.

en	An algorithm should never depend on the way that incoming or outgoing

en	Messages can be either text or binary. A message sent as text must contain consist of valid utf8, while a message sent as binary may contain arbitrary data. In addition to message frames, websocket provides ['control frames] in the form of ping, pong, and close messages which have a small upper limit on their payload size. Depending on how a message is framed, control frames may have more opportunities to be sent in-between.

en	Sending

en	These stream members are used to write websocket messages:

en	WebSocket Stream Write Operations

en	Function

en	Description

en	[link beast.ref.boost__beast__websocket__stream.write.overload2 `write`], [link beast.ref.boost__beast__websocket__stream.async_write `async_write`]

en	Send a buffer sequence as a complete message.

en	[link beast.ref.boost__beast__websocket__stream.write_some.overload2 `write_some`], [link beast.ref.boost__beast__websocket__stream.async_write_some `async_write_some`]

en	Send a buffer sequence as part of a message.

en	This example shows how to send a buffer sequence as a complete message.

en	The same message could be sent in two or more frames thusly.

en	Receiving

en	WebSocket Stream Read Operations

en	Function

en	Description

en	[link beast.ref.boost__beast__websocket__stream.read.overload2 `read`], [link beast.ref.boost__beast__websocket__stream.async_read `async_read`]

en	Read a complete message into a __DynamicBuffer__.

en	[link beast.ref.boost__beast__websocket__stream.read_some.overload2 `read_some`], [link beast.ref.boost__beast__websocket__stream.async_read_some.overload1 `async_read_some`]

en	Read part of a message into a __DynamicBuffer__.

en	[link beast.ref.boost__beast__websocket__stream.read_some.overload4 `read_some`], [link beast.ref.boost__beast__websocket__stream.async_read_some.overload2 `async_read_some`]

en	Read part of a message into a __MutableBufferSequence__.

en	After the WebSocket handshake is accomplished, callers may send and receive messages using the message oriented interface. This interface requires that all of the buffers representing the message are known ahead of time:

en	Frames

en	Some use-cases make it impractical or impossible to buffer the entire message ahead of time:

en	* Streaming multimedia to an endpoint. * Sending a message that does not fit in memory at once. * Providing incremental results as they become available.

en	For these cases, the partial data oriented interface may be used. This example reads and echoes a complete message using this interface: