QcFrameReader Class
Framing of the protocol on a byte stream (TCP, decision E-251): every frame is a big-endian quint32 length followed by that many bytes; a frame of length 0 only keeps the connection alive. More...
| Header: | #include <common/protocol/QcFrameReader.h> |
Public Functions
| bool | append(QByteArrayView bytes) |
| qsizetype | buffered() const |
| bool | failed() const |
| std::optional<QByteArray> | next() |
Static Public Members
| QByteArray | header(qsizetype size) |
| const qsizetype | headerBytes |
Detailed Description
The reader collects arbitrary fragments and hands out whole frames; a length beyond the limit breaks the stream for good (the peer is broken or hostile).
Member Function Documentation
bool QcFrameReader::append(QByteArrayView bytes)
Takes bytes, more of the stream. Returns false once a frame announced more than the limit.
qsizetype QcFrameReader::buffered() const
Returns the bytes received but not yet handed out.
bool QcFrameReader::failed() const
Returns whether a frame announced more than the limit; the stream is broken for good.
[static] QByteArray QcFrameReader::header(qsizetype size)
Returns the length prefix for a frame of size bytes.
std::optional<QByteArray> QcFrameReader::next()
Returns the next complete frame (empty for a keep-alive), or nothing until more bytes arrive.
Member Variable Documentation
const qsizetype QcFrameReader::headerBytes
The size of the length prefix.