Both Windows and Unix provide synchronous DNS lookups; Windows provides some asynchronous support too. At the time of writing neither operating system provides asynchronous support for anything other than hostname-to-address mapping.
.PP
QDns rectifies this shortcoming, by providing asynchronous caching lookups for the record types that we expect modern GUI applications to need in the near future.
.PP
The class is \fInot\fR straightforward to use (although it is much simpler than the native APIs); QSocket provides much easier to use TCP connection facilities. The aim of QDns is to provide a correct and small API to the DNS and nothing more. (We use "correctness" to mean that the DNS information is correctly cached, and correctly timed out.)
.PP
The API comprises a constructor, functions to set the DNS node (the domain in DNS terminology) and record type (setLabel() and setRecordType()), the corresponding get functions, an isWorking() function to determine whether QDns is working or reading, a resultsReady() signal and query functions for the result.
.PP
There is one query function for each RecordType, namely addresses(), mailServers(), servers(), hostNames() and texts(). There are also two generic query functions: canonicalName() returns the name you'll presumably end up using (the exact meaning of this depends on the record type) and qualifiedNames() returns a list of the fully qualified names label() maps to.
.PP
See also QSocket and Input/Output and Networking.
.SS "Member Type Documentation"
.SH "QDns::RecordType"
This enum type defines the record types QDns can handle. The DNS provides many more; these are the ones we've judged to be in current use, useful for GUI programs and important enough to support right away:
.TP
\fCQDns::None\fR - No information. This exists only so that QDns can have a default.
.TP
\fCQDns::A\fR - IPv4 addresses. By far the most common type.
.TP
\fCQDns::Aaaa\fR - IPv6 addresses. So far mostly unused.
.TP
\fCQDns::Mx\fR - Mail eXchanger names. Used for mail delivery.
.TP
\fCQDns::Srv\fR - SeRVer names. Generic record type for finding servers. So far mostly unused.
.TP
\fCQDns::Cname\fR - Canonical names. Maps from nicknames to the true name (the canonical name) for a host.
.TP
\fCQDns::Ptr\fR - name PoinTeRs. Maps from IPv4 or IPv6 addresses to hostnames.
.TP
\fCQDns::Txt\fR - arbitrary TeXT for domains.
.PP
We expect that some support for the RFC-2535 extensions will be added in future versions.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QDns::QDns ()"
Constructs a DNS query object with invalid settings for both the label and the search type.
Constructs a DNS query object that will return record type \fIrr\fR information about host address \fIaddress\fR. The label is set to the IN-ADDR.ARPA domain name. This is useful in combination with the Ptr record type (e.g. if you want to look up a hostname for a given address).
.PP
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted.
.PP
\fIrr\fR defaults to Ptr, that maps addresses to hostnames.
.SH "QDns::~QDns ()\fC [virtual]\fR"
Destroys the DNS query object and frees its allocated resources.
Returns a list of the addresses for this name if this QDns object has a recordType() of QDns::A or QDns::Aaaa and the answer is available; otherwise returns an empty list.
.PP
As a special case, if label() is a valid numeric IP address, this function returns that address.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
.PP
.nf
.br
QValueList<QHostAddress> list = myDns.addresses();
.br
QValueList<QHostAddress>::Iterator it = list.begin();
Returns the canonical name for this DNS node. (This works regardless of what recordType() is set to.)
.PP
If the canonical name isn't known, this function returns a null string.
.PP
The canonical name of a DNS node is its full name, or the full name of the target of its CNAME. For example, if l.trolltech.com is a CNAME to lillian.troll.no, and the search path for QDns is" trolltech.com", then the canonical name for all of "lillian"," l", "lillian.troll.no." and "l.trolltech.com" is" lillian.troll.no.".
.SH "QStringList QDns::hostNames () const"
Returns a list of host names if the record type is Ptr.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
.PP
.nf
.br
QStringList list = myDns.hostNames();
.br
QStringList::Iterator it = list.begin();
.br
while( it != list.end() ) {
.br
myProcessing( *it );
.br
++it;
.br
}
.br
.fi
.SH "bool QDns::isWorking () const"
Returns TRUE if QDns is doing a lookup for this object (i.e. if it does not already have the necessary information); otherwise returns FALSE.
.PP
QDns emits the resultsReady() signal when the status changes to FALSE.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets this DNS query object to query for information about the host address \fIaddress\fR. The label is set to the IN-ADDR.ARPA domain name. This is useful in combination with the Ptr record type (e.g. if you want to look up a hostname for a given address).
.SH "void QDns::setRecordType ( RecordType rr = A )\fC [virtual]\fR"
Sets this object to query for record type \fIrr\fR records.
.PP
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted.
.PP
See also RecordType.
.SH "QStringList QDns::texts () const"
Returns a list of texts if the record type is Txt.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.