template<typename T, typename
TSocket>
class NNet::TStructReader< T, TSocket >
A utility for reading a fixed-size structure of type T
from a socket-like object.
This class expects the socket to provide a method TValueTask<ssize_t> ReadSome(void* buffer, size_t size)
, which returns:
- 0 if the connection is closed,
- 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).
- Template Parameters
-
T | A trivially copyable (or otherwise byte-serializable) type that can be read directly into memory. |
TSocket | The socket type used for reading, offering the required ReadSome() method. |
Example Usage
struct MyData {
int Id;
float Value;
};
TValueTask<void> ExampleFunction(
TSocket& socket) {
MyData data = co_await reader.Read();
co_return;
}
High-level asynchronous socket for network communication.
Definition socket.hpp:364
A utility for reading a fixed-size structure of type T from a socket-like object.
Definition sockutils.hpp:288