A utility for reading data from a socket-like object, either a fixed number of bytes or until a specified delimiter.
More...
template<typename
TSocket>
class NNet::TByteReader< TSocket >
A utility for reading data from a socket-like object, either a fixed number of bytes or until a specified delimiter.
This class manages an internal buffer so that any data read beyond what is immediately requested can be stored and used in subsequent reads.
- Template Parameters
-
TSocket | The socket type used for reading bytes. It must provide a method TFuture<ssize_t> ReadSome(void* buffer, size_t size) which returns:
- 0 on connection closure,
- a positive number for the count of bytes successfully read,
- a negative number to indicate a recoverable read error (in which case a retry may be attempted).
|
Example Usage
char data[128];
co_await reader.Read(data, sizeof(data));
std::string line = co_await reader.ReadUntil("\r\n");
co_return;
}
High-level asynchronous socket for network communication.
Definition socket.hpp:364
TByteReader(TSocket &socket)
Constructs a reader for the given socket.
Definition sockutils.hpp:60
Future type for coroutines returning a value of type T.
Definition corochain.hpp:177