| 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 | { |
no test coverage detected