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.
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.
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.