QDns(3qt)
๐ธ NAME ๐ธ
QDns โ Asynchronous DNS lookups ๐ซ
bestie this is the whole vibe: DNS queries that don't block your app while the internet is out there doing internet things.
๐ฆ SYNOPSIS ๐ฆ
#include <qdns.h>
Inherits QObject.
๐ Public Members ๐
enum RecordType { None, A, Aaaa, Mx, Srv, Cname, Ptr, Txt }QDns ()QDns ( const QString & label, RecordType rr = A )QDns ( const QHostAddress & address, RecordType rr = Ptr )virtual ~QDns ()virtual void setLabel ( const QString & label )virtual void setLabel ( const QHostAddress & address )QString label () constvirtual void setRecordType ( RecordType rr = A )RecordType recordType () constbool isWorking () constQValueList<QHostAddress> addresses () constQValueList<MailServer> mailServers () constQValueList<Server> servers () constQStringList hostNames () constQStringList texts () constQString canonicalName () constQStringList qualifiedNames () const
โจ Signals โจ
void resultsReady ()
๐ DESCRIPTION ๐
okay so, QDns is literally the class that gives you asynchronous DNS lookups. no cap. ๐ฅ
Here's the tea: both Windows and Unix hand you synchronous DNS lookups, and Windows throws in a lil bit of asynchronous support too. But at the time of writing, neither operating system gives you async support for anything except hostname-to-address mapping. sad. ๐ญ
QDns rectifies this shortcoming ๐
by serving up asynchronous caching lookups for the record types that we expect modern GUI applications to need in the near future. iconic behaviour honestly.
The class is not straightforward to use (although it is much simpler than the native APIs); QSocket provides much easier to use TCP connection facilities. The whole aim of QDns is to provide a correct and small API to the DNS and nothing more. (When we say "correctness" we mean that the DNS information is correctly cached, and correctly timed out.) periodt.
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.
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.
๐ See also QSocket and Input/Output and Networking.
๐ฅ Member Type Documentation ๐ฅ
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:
QDns::Noneโ No information. This exists only so thatQDnscan have a default. ๐QDns::Aโ IPv4 addresses. By far the most common type. ๐QDns::Aaaaโ IPv6 addresses. So far mostly unused.QDns::Mxโ Mail eXchanger names. Used for mail delivery. ๐ฌQDns::Srvโ SeRVer names. Generic record type for finding servers. So far mostly unused.QDns::Cnameโ Canonical names. Maps from nicknames to the true name (the canonical name) for a host.QDns::Ptrโ name PoinTeRs. Maps from IPv4 or IPv6 addresses to hostnames.QDns::Txtโ arbitrary TeXT for domains. ๐
We expect that some support for the RFC-2535 extensions will be added in future versions. ๐ฎ
๐ MEMBER FUNCTION DOCUMENTATION ๐
QDns::QDns ()
Constructs a DNS query object with invalid settings for both the label and the search type. it's giving "blank canvas, nothing decided yet" โจ
QDns::QDns ( const QString & label, RecordType rr = A )
Constructs a DNS query object that will return record type rr information about label.
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted. ๐
rr defaults to A, IPv4 addresses.
QDns::QDns ( const QHostAddress & address, RecordType rr = Ptr )
Constructs a DNS query object that will return record type rr information about host address address. 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). ๐ต๏ธโ๏ธ
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted.
rr defaults to Ptr, that maps addresses to hostnames.
QDns::~QDns () [virtual]
Destroys the DNS query object and frees its allocated resources. bye bestie, clean exit ๐
QValueList<QHostAddress> QDns::addresses () const
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.
As a special case, if label() is a valid numeric IP address, this function returns that address. โจ
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QValueList<QHostAddress> list = myDns.addresses();
QValueList<QHostAddress>::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
๐ซถ fr fr, copy that list first. iterating the original while it's still live is not the move.
QString QDns::canonicalName () const
Returns the canonical name for this DNS node. (This works regardless of what recordType() is set to.) ๐
If the canonical name isn't known, this function returns a null string.
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.. ๐ฆ
QStringList QDns::hostNames () const
Returns a list of host names if the record type is Ptr.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QStringList list = myDns.hostNames();
QStringList::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
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.
QDns emits the resultsReady() signal when the status changes to FALSE. ๐ฃ
Example: network/mail/smtp.cpp.
QString QDns::label () const
Returns the domain name for which this object returns information.
๐ See also setLabel().
QValueList<MailServer> QDns::mailServers () const
Returns a list of mail servers if the record type is Mx. The class QDns::MailServer contains the following public variables:
QString QDns::MailServer::nameQ_UINT16 QDns::MailServer::priority
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QValueList<QDns::MailServer> list = myDns.mailServers();
QValueList<QDns::MailServer>::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
Example: network/mail/smtp.cpp.
QStringList QDns::qualifiedNames () const
Returns a list of the fully qualified names label() maps to.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QStringList list = myDns.qualifiedNames();
QStringList::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
RecordType QDns::recordType () const
Returns the record type of this DNS query object.
๐ See alsosetRecordType()andRecordType.
void QDns::resultsReady () [signal]
This signal is emitted when results are available for one of the qualifiedNames(). ๐
Example: network/mail/smtp.cpp.
QValueList<Server> QDns::servers () const
Returns a list of servers if the record type is Srv. The class QDns::Server contains the following public variables:
QString QDns::Server::nameQ_UINT16 QDns::Server::priorityQ_UINT16 QDns::Server::weightQ_UINT16 QDns::Server::port
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QValueList<QDns::Server> list = myDns.servers();
QValueList<QDns::Server>::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
void QDns::setLabel ( const QString & label ) [virtual]
Sets this DNS query object to query for information about label.
This does not change the recordType(), but its isWorking() status will probably change as a result.
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted. โจ
void QDns::setLabel ( const QHostAddress & address ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function. ๐
Sets this DNS query object to query for information about the host address address. 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).
void QDns::setRecordType ( RecordType rr = A ) [virtual]
Sets this object to query for record type rr records.
The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emitted.
๐ See also RecordType.
QStringList QDns::texts () const
Returns a list of texts if the record type is Txt.
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
QStringList list = myDns.texts();
QStringList::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
๐ SEE ALSO ๐
๐ COPYRIGHT ๐
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
๐ AUTHOR ๐
Generated automatically from the source code. (yes bestie, a robot wrote it, and it ate ๐ )
๐ BUGS ๐
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. ๐
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qdns.3qt) and the Qt version (3.3.8). ๐ฎ
and that's the whole page, bestie ๐ซถ this one's a Trolltech AS situation, dated 2 February 2007, and it's shipping with Qt version 3.3.8 โ go forth and resolve some names asynchronously, you absolute main character ๐โจ
๐ฆ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 ยท QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 ยท QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms