Read exactly n bytes from the socket. If deadline_ns is non-zero, abort when the monotonic clock exceeds it.
| 134 | /// Read exactly n bytes from the socket. |
| 135 | /// If deadline_ns is non-zero, abort when the monotonic clock exceeds it. |
| 136 | bool readExact(Poco::Net::StreamSocket & socket, char * buf, size_t n, UInt64 deadline_ns = 0) |
| 137 | { |
| 138 | size_t total = 0; |
| 139 | while (total < n) |
| 140 | { |
| 141 | if (deadline_ns && clock_gettime_ns() > deadline_ns) |
| 142 | return false; |
| 143 | int received = socket.receiveBytes(buf + total, static_cast<int>(n - total)); |
| 144 | if (received <= 0) |
| 145 | return false; |
| 146 | total += static_cast<size_t>(received); |
| 147 | } |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | struct WebSocketFrame |
| 152 | { |
no test coverage detected