Qt logo

QDns Class Reference


The QDns class provides asynchronous DNS lookups. This class is part of the Qt Network Extension. More...

#include <qdns.h>

Inherits QObject.

List of all member functions.

Public Members

Signals


Detailed Description

This class is defined in the Qt Network Extension, which can be found in the qt/extensions directory. It is not included in the main Qt API.

The QDns class provides asynchronous DNS lookups.

Both Windows and UNIX provides synchronous DNS lookups; Windows provides some asynchronous support too. Neither OS provides asynchronous support for anything other than hostname-to-address mapping.

QDns rectifies that, by providing asynchronous caching lookups for the record types that we expect modern GUI applications to need in the near future.

The class is a bit hard to use (although much simpler than the native APIs); QSocket provides much simpler TCP connection facilities. The aim of QDns is to provide a correct and small API to the DNS: Nothing more. (Correctness implies that the DNS information is correctly cached, and correctly timed out.)

The API is made up of a constructor, functions to set the DNS node (the domain in DNS terminology) and record type: setLabel() and setRecordType(), the corresponding getters, an isWorking() function to determine whether QDns is working or reading, a resultsReady() signal, and finally query functions for the result.

There is one query function for each RecordType, namely addresses(), mailServers(), servers() and texts(). There are also two generic query functions: canonicalName() return the name you'll presumably end up using (the exact meaning of that depends on the record type) and qualifiedNames() returns a list of the fully qualified names label() maps to.


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:

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 both for the label and the search type.

QDns::QDns ( const QString & label, RecordType rr = A )

Constructs a DNS query object that will return rr information about label.

rr defaults to A, IPv4 addresses.

QDns::~QDns ()

Destroys the query object and frees its allocated resources.

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, or an empty list else.

As a special case, if label() is a valid numeric IP address, this function returns that address.

bool QDns::isWorking () const

Returns TRUE if QDns is doing a lookup for this object, and FALSE if this object has the information it wants.

QDns emits the resultsReady() signal when the status changes to FALSE.

QString QDns::label () const

Returns the domain name for which this object returns information.

See also: setLabel().

QDns::RecordType QDns::recordType() const

Returns the record type of this query object.

See also: setRecordType() and RecordType.

void QDns::setLabel ( const QString & label ) [virtual]

Sets this query object to query for information about label. This does not change the recordType(), but its isWorking() most likely changes as a result.

void QDns::setRecordType ( RecordType rr = A ) [virtual]

Sets this object to query for rr records.

See also: RecordType.


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-2000 Troll Tech, all rights reserved.


Copyright İ 2000 Troll TechTrademarks
Qt version 2.1.0 (pre-release)