* @brief Receive and decode length header. * @returns The expected length received. * @throws socket_exception */
| 238 | * @throws socket_exception |
| 239 | */ |
| 240 | uint32_t dgram_over_stream::receive_header(void) { |
| 241 | ssize_t pos = 0; |
| 242 | |
| 243 | do { |
| 244 | ssize_t result = |
| 245 | inner->rcv(prefix_buffer + pos, FRAMING_PREFIX_LENGTH, 0); |
| 246 | |
| 247 | if (result < 0) |
| 248 | throw socket_exception(__FILE__, __LINE__, |
| 249 | "dgram_over_stream::receive_header(): Could " |
| 250 | "not receive length prefix!", |
| 251 | false); |
| 252 | |
| 253 | pos += result; |
| 254 | } while (pos < 4); |
| 255 | |
| 256 | return decode_uint32(prefix_buffer); |
| 257 | } |
| 258 | } // namespace libsocket |
| 259 | |
| 260 | /** |
nothing calls this directly
no test coverage detected