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

Function TryReceiveMatchingQuestion

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

Source from the content-addressed store, hash-verified

931 }
932
933 static bool TryReceiveMatchingQuestion(dmSocket::Socket socket, const char* qname, uint16_t qtype, RawDnsPacket* packet)
934 {
935 uint8_t buffer[1500];
936 for (;;)
937 {
938 dmSocket::Address from_address;
939 uint16_t from_port = 0;
940 int received = 0;
941 dmSocket::Result r = dmSocket::ReceiveFrom(socket, buffer, sizeof(buffer), &received, &from_address, &from_port);
942 if (r == dmSocket::RESULT_WOULDBLOCK)
943 return false;
944 if (r != dmSocket::RESULT_OK || received <= 0)
945 return false;
946
947 RawDnsPacket candidate;
948 if (ParseDnsPacket(buffer, (uint32_t) received, &candidate)
949 && !candidate.m_IsResponse
950 && HasQuestion(candidate, qname, qtype, DNS_CLASS_IN))
951 {
952 *packet = candidate;
953 return true;
954 }
955 }
956 }
957
958 static bool WaitForMatchingResponse(dmMDNS::HMDNS mdns, dmSocket::Socket socket, const std::vector<std::string>& names, RawDnsPacket* packet, uint32_t timeout_ms)
959 {

Callers 1

WaitForMatchingQuestionFunction · 0.85

Calls 3

ParseDnsPacketFunction · 0.85
HasQuestionFunction · 0.85
ReceiveFromFunction · 0.50

Tested by

no test coverage detected