MCPcopy Create free account
hub / github.com/NetSys/bess / RecvString

Method RecvString

core/utils/fifo_test.cc:286–302  ·  view source on GitHub ↗

Receives a string. Returns true if it gets one. See SendString.

Source from the content-addressed store, hash-verified

284
285// Receives a string. Returns true if it gets one. See SendString.
286bool PtoP::RecvString(int fd, std::string *str, size_t maxlen) {
287 char buf[maxlen];
288 for (int tries = 0; tries < kMaxTries;) {
289 ssize_t nread = read(fd, buf, sizeof buf);
290 if (nread > 0) {
291 *str = std::string(buf, nread);
292 return true;
293 }
294 if (nread != -1 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
295 break;
296 }
297 if (++tries < kMaxTries) {
298 std::this_thread::sleep_for(short_sleep);
299 }
300 }
301 return false;
302}
303
304// Send message to parent or child, figuring out which way
305// automatically.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected