◆ close()
| void tt::PacketBuffer::close |
( |
| ) |
|
|
inlinenoexcept |
Close the connection on this side.
◆ closed()
| bool tt::PacketBuffer::closed |
( |
| ) |
const |
|
inlinenoexcept |
Connection is closed.
- Returns
- true when the connection has be closed.
◆ getNewPacket()
| nonstd::span< std::byte > tt::PacketBuffer::getNewPacket |
( |
ssize_t | nrBytes | ) |
|
|
inlinenoexcept |
Get a new packet to write a message into.
- Returns
- a pointer to an byte array with at least nrBytes of data available.
◆ getPacket()
| nonstd::span< std::byte > tt::PacketBuffer::getPacket |
( |
ssize_t | nrBytes | ) |
|
|
inlinenoexcept |
Get a packet to write a stream of bytes into.
- Returns
- a pointer to an byte array with at least nrBytes of data available.
◆ nrBytes()
| ssize_t tt::PacketBuffer::nrBytes |
( |
| ) |
const |
|
inlinenoexcept |
Total number of bytes in the buffer.
◆ nrPackets()
| ssize_t tt::PacketBuffer::nrPackets |
( |
| ) |
const |
|
inlinenoexcept |
Total number of packets in the buffer.
This contains the number of messages on a message based socket. On a stream based socket this number is not useful, but larger than zero when data is available.
◆ peek()
| nonstd::span< std::byte const > tt::PacketBuffer::peek |
( |
ssize_t | nrBytes | ) |
|
|
inline |
Peek into the data without consuming.
- Parameters
-
| nrBytes | the minimum amount of data required. |
- Returns
- empty if not enough bytes available; otherwise the data. The returned size may be larger than requested and this data may be consumed using
read().
◆ peekLine()
| std::string_view tt::PacketBuffer::peekLine |
( |
ssize_t | nrBytes = 1024 | ) |
|
|
inline |
Peek into the data a single text-line without consuming.
Throws parse_error when the line is longer than nrBytes.
- Parameters
-
- Returns
- empty if there are no lines; otherwise a line of data. The line-feed or nul is included at the end of the string.
◆ read()
| void tt::PacketBuffer::read |
( |
ssize_t | nrBytes | ) |
|
|
inlinenoexcept |
Consume the data from the buffer.
This function will consume the data read using peek() and peekLine().
- Parameters
-
| nrByted | The number of bytes to consume. |
◆ write()
| void tt::PacketBuffer::write |
( |
ssize_t | nrBytes, |
|
|
bool | push = true ) |
|
inlinenoexcept |
Write the data added to the packet.
This function will write the data added into the buffers returned by getNewPacket() and getPacket().
- Parameters
-
| nrByted | The number of bytes written into the packet. |
| push | Push the data through the socket, bypass Nagel algorithm. |
The documentation for this class was generated from the following file: