MCPcopy Create free account
hub / github.com/clementgallet/libTAS / receiveData

Function receiveData

src/shared/sockethelpers.cpp:229–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229int receiveData(void* elem, unsigned int size)
230{
231#ifdef LIBTAS_LIBRARY
232 LOG(LL_DEBUG, LCF_SOCKET, "Receive socket data of size %u", size);
233#endif
234
235 ssize_t ret = 0;
236 do {
237 ret = recv(socket_fd, elem, size, MSG_WAITALL);
238 } while ((ret == -1) && (errno == EINTR));
239
240 if (ret == -1) {
241#ifdef LIBTAS_LIBRARY
242 LOG(LL_ERROR, LCF_SOCKET, "recv() returns -1 with error %s", strerror(errno));
243#else
244 std::cerr << "recv() returns -1 with error " << strerror(errno) << std::endl;
245#endif
246 }
247 else if (ret == 0 && size > 0) { // socket has been closed
248#ifdef LIBTAS_LIBRARY
249 LOG(LL_WARN, LCF_SOCKET, "recv() returns 0 -> socket closed");
250#else
251 std::cerr << "recv() returns 0 -> socket closed" << std::endl;
252#endif
253 }
254 else if (ret != static_cast<ssize_t>(size)) {
255#ifdef LIBTAS_LIBRARY
256 LOG(LL_ERROR, LCF_SOCKET, "recv() %u bytes instead of %u", ret, size);
257#else
258 std::cerr << "recv() " << ret << " bytes instead of " << size << std::endl;
259#endif
260 }
261 return ret;
262}
263
264int receiveMessage()
265{

Callers 13

receive_messagesFunction · 0.85
hook_patchFunction · 0.85
initFunction · 0.85
processSocketMethod · 0.85
receiveMessageFunction · 0.85
receiveStringFunction · 0.85
receiveCStringFunction · 0.85
recvMethod · 0.85
initProcessMessagesMethod · 0.85
startFrameMessagesMethod · 0.85
processInputsMethod · 0.85
postLoadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected