MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / receive

Method receive

deps/cpp-statsd-client/tests/StatsdServer.hpp:53–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 }
52
53 std::string receive() noexcept {
54 // If uninitialized then bail
55 if (!detail::isValidSocket(m_socket)) {
56 return "";
57 }
58
59 // Try to receive (this is blocking)
60 std::string buffer(256, '\0');
61 int string_len;
62 if ((string_len = recv(m_socket, &buffer[0], static_cast<int>(buffer.size()), 0)) < 1) {
63 m_errorMessage = "Could not recv on the socket file descriptor";
64 return "";
65 }
66
67 // No error return the trimmed result
68 m_errorMessage.clear();
69 buffer.resize(std::min(static_cast<size_t>(string_len), buffer.size()));
70 return buffer;
71 }
72
73private:
74 SOCKET_TYPE m_socket;

Callers 2

mockFunction · 0.80
throwOnWrongMessageFunction · 0.80

Calls 3

isValidSocketFunction · 0.85
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected