MCPcopy Create free account
hub / github.com/defold/defold / DrainSocket

Function DrainSocket

engine/dlib/src/test/test_mdns.cpp:888–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886 }
887
888 static void DrainSocket(dmSocket::Socket socket, uint32_t duration_ms)
889 {
890 const uint64_t deadline = dmTime::GetMonotonicTime() + (uint64_t) duration_ms * 1000ULL;
891 uint8_t buffer[1500];
892 while (dmTime::GetMonotonicTime() < deadline)
893 {
894 dmSocket::Address from_address;
895 uint16_t from_port = 0;
896 int received = 0;
897 dmSocket::Result r = dmSocket::ReceiveFrom(socket, buffer, sizeof(buffer), &received, &from_address, &from_port);
898 if (r == dmSocket::RESULT_WOULDBLOCK)
899 {
900 dmTime::Sleep(5 * 1000);
901 continue;
902 }
903 if (r != dmSocket::RESULT_OK)
904 return;
905 }
906 }
907
908 static bool TryReceiveMatchingResponse(dmSocket::Socket socket, const std::vector<std::string>& names, RawDnsPacket* packet)
909 {

Callers 3

WaitForOnlyResponseTxtIdFunction · 0.85
SendQueryAndCaptureFunction · 0.85
TESTFunction · 0.85

Calls 3

GetMonotonicTimeFunction · 0.50
ReceiveFromFunction · 0.50
SleepFunction · 0.50

Tested by

no test coverage detected