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

Function WaitForOnlyResponseTxtId

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

Source from the content-addressed store, hash-verified

1046 }
1047
1048 static bool WaitForOnlyResponseTxtId(dmMDNS::HMDNS mdns_a, dmMDNS::HMDNS mdns_b, dmSocket::Socket capture_socket,
1049 dmSocket::Socket sender_socket, const std::vector<uint8_t>& query,
1050 const char* full_service_name, const char* expected_id, uint32_t timeout_ms)
1051 {
1052 const uint64_t deadline = dmTime::GetMonotonicTime() + (uint64_t) timeout_ms * 1000ULL;
1053 for (;;)
1054 {
1055 const uint64_t now = dmTime::GetMonotonicTime();
1056 if (now >= deadline)
1057 break;
1058
1059 // Prior multicast announcements can still be queued on the capture socket.
1060 // Drain before each fresh query so stale packets cannot decide the race.
1061 DrainSocket(capture_socket, 100);
1062 if (!SendPacketToAddress(sender_socket, &query[0], (uint32_t) query.size(), MDNS_MULTICAST_IPV4, MDNS_PORT))
1063 return false;
1064
1065 std::set<std::string> ids;
1066 CollectResponseTxtIds(mdns_a, mdns_b, capture_socket, full_service_name, 500, &ids);
1067 if (ids.size() == 1 && ids.find(expected_id) != ids.end())
1068 return true;
1069 }
1070
1071 return false;
1072 }
1073
1074 static bool SendQueryAndCapture(dmMDNS::HMDNS mdns, dmSocket::Socket socket, const char* qname, uint16_t qtype, const std::vector<std::string>& names, RawDnsPacket* packet, uint32_t timeout_ms)
1075 {

Callers 1

TESTFunction · 0.85

Calls 7

DrainSocketFunction · 0.85
SendPacketToAddressFunction · 0.85
CollectResponseTxtIdsFunction · 0.85
GetMonotonicTimeFunction · 0.50
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected