MCPcopy Create free account
hub / github.com/dermesser/libsocket / receive_bytes

Method receive_bytes

C++/dgramoverstream.cpp:216–233  ·  view source on GitHub ↗

Places up to n bytes into this->RECV_BUF.

Source from the content-addressed store, hash-verified

214
215// Places up to n bytes into this->RECV_BUF.
216ssize_t dgram_over_stream::receive_bytes(size_t n) {
217 if (n == 0) return 0;
218
219 // Ignore rest of message.
220 ssize_t rest_len = n > RECV_BUF_SIZE ? RECV_BUF_SIZE : n;
221 size_t pos = 0;
222
223 while (rest_len > 0) {
224 ssize_t recvd = inner->rcv(RECV_BUF + pos, rest_len, 0);
225
226 if (recvd <= 0) return n - rest_len;
227
228 rest_len -= recvd;
229 pos += recvd;
230 }
231
232 return pos;
233}
234
235/**
236 * @brief Receive and decode length header.

Callers

nothing calls this directly

Calls 1

rcvMethod · 0.45

Tested by

no test coverage detected