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

Function TryReceiveMatchingResponse

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

Source from the content-addressed store, hash-verified

906 }
907
908 static bool TryReceiveMatchingResponse(dmSocket::Socket socket, const std::vector<std::string>& names, RawDnsPacket* packet)
909 {
910 uint8_t buffer[1500];
911 for (;;)
912 {
913 dmSocket::Address from_address;
914 uint16_t from_port = 0;
915 int received = 0;
916 dmSocket::Result r = dmSocket::ReceiveFrom(socket, buffer, sizeof(buffer), &received, &from_address, &from_port);
917 if (r == dmSocket::RESULT_WOULDBLOCK)
918 return false;
919 if (r != dmSocket::RESULT_OK || received <= 0)
920 return false;
921
922 RawDnsPacket candidate;
923 if (ParseDnsPacket(buffer, (uint32_t) received, &candidate)
924 && candidate.m_IsResponse
925 && PacketMatchesNames(candidate, names))
926 {
927 *packet = candidate;
928 return true;
929 }
930 }
931 }
932
933 static bool TryReceiveMatchingQuestion(dmSocket::Socket socket, const char* qname, uint16_t qtype, RawDnsPacket* packet)
934 {

Callers 2

WaitForMatchingResponseFunction · 0.85
CollectResponseTxtIdsFunction · 0.85

Calls 3

ParseDnsPacketFunction · 0.85
PacketMatchesNamesFunction · 0.85
ReceiveFromFunction · 0.50

Tested by

no test coverage detected