c++dnsqt5qhostaddress

Correct way to look up Hostnames in Qt with QHostInfo or QDnsLookUp


I am trying to use QHostInfo or QDnsLookUp to look up a hostname and get a list of QHostAddress. I would prefer QHostInfo (the interface is simpler) but I tried also QDnsLookUp.

In the first case, I use QHostInfo::lookupHost() static function, and then I get the addresses from the result with QHostInfo::addresses()

In the second case I use QDnsLookup::lookup(), with the type set to QDnsLookup::A (IPv4 address records) and I get the results with QDnsLookup::hostAddressRecords() (and I get the value of the QDnsHostAddressRecord elements).

Well, both methods work somehow, but I get only one result...in both cases it should be a list of results from the documentation...but my list contains only one element...

Is there some option or something else that I should set to get the complete list? What could have gone wrong?


Solution

  • With the help of Dig - Google Apps I found out that the QDnsLookup::A option was not the correct solution. I have to use QDnsLookup::ANY in order to have a complete list.