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

Function SendQueryAndCapture

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

Source from the content-addressed store, hash-verified

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 {
1076 std::vector<uint8_t> query;
1077 BuildQueryPacket(qname, qtype, &query);
1078
1079 // mDNS traffic is asynchronous and prior announcements may still be queued
1080 // on the capture socket. Drain them so this helper only observes replies
1081 // caused by the query we are about to send.
1082 DrainSocket(socket, 10);
1083
1084 int sent = 0;
1085 if (dmSocket::SendTo(socket, &query[0], (int) query.size(), &sent, dmSocket::AddressFromIPString(MDNS_MULTICAST_IPV4), MDNS_PORT) != dmSocket::RESULT_OK
1086 || sent != (int) query.size())
1087 {
1088 return false;
1089 }
1090
1091 return WaitForMatchingResponse(mdns, socket, names, packet, timeout_ms);
1092 }
1093
1094 static bool QueryProducesNoMatchingResponse(dmMDNS::HMDNS mdns, dmSocket::Socket socket, const char* qname, uint16_t qtype, const std::vector<std::string>& names, uint32_t timeout_ms)
1095 {

Callers 2

TESTFunction · 0.85

Calls 6

BuildQueryPacketFunction · 0.85
DrainSocketFunction · 0.85
AddressFromIPStringFunction · 0.85
WaitForMatchingResponseFunction · 0.85
SendToFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected