| 886 | } |
| 887 | |
| 888 | static void DrainSocket(dmSocket::Socket socket, uint32_t duration_ms) |
| 889 | { |
| 890 | const uint64_t deadline = dmTime::GetMonotonicTime() + (uint64_t) duration_ms * 1000ULL; |
| 891 | uint8_t buffer[1500]; |
| 892 | while (dmTime::GetMonotonicTime() < deadline) |
| 893 | { |
| 894 | dmSocket::Address from_address; |
| 895 | uint16_t from_port = 0; |
| 896 | int received = 0; |
| 897 | dmSocket::Result r = dmSocket::ReceiveFrom(socket, buffer, sizeof(buffer), &received, &from_address, &from_port); |
| 898 | if (r == dmSocket::RESULT_WOULDBLOCK) |
| 899 | { |
| 900 | dmTime::Sleep(5 * 1000); |
| 901 | continue; |
| 902 | } |
| 903 | if (r != dmSocket::RESULT_OK) |
| 904 | return; |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | static bool TryReceiveMatchingResponse(dmSocket::Socket socket, const std::vector<std::string>& names, RawDnsPacket* packet) |
| 909 | { |
no test coverage detected