How do you asynchronously resolve host names to IP addresses?
-
24-05-2021 - |
Question
How do you asynchronously resolve host names to IP addresses, preferably with overlapped I/O? GetAddrInfoEx does not support overlapped I/O in Windows 7 and earlier.
I am using native C++.
Solution
For the record, this can be done natively on Windows 7, like this:
- DnsWriteQuestionToBuffer to compose DNS queries yourself for sending.
- DnsExtractRecordsFromMessage to parse DNS responses yourself after receiving.
- WSASendTo in conjunction with WSARecvFrom in a IOCP server for async sending and receiving of DNS queries.
The side effect of this technique is that it's by no means a feat for a novice to easily pull.
OTHER TIPS
libunbound
has an asynchronous resolver in it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow