Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QDns Class Reference
[ network module ]


The QDns class provides asynchronous DNS lookups. More...

#include <qdns.h>

Inherits QObject.

List of all member functions.

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 () const
  • virtual void setRecordType ( RecordType rr = A ) 
  • RecordType recordType () const
  • bool isWorking () const
  • QValueList<QHostAddress> addresses () const
  • QValueList<MailServer> mailServers () const
  • QValueList<Server> servers () const
  • QStringList hostNames () const
  • QStringList texts () const
  • QString canonicalName () const
  • QStringList qualifiedNames () const

Signals


Detailed Description

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(), hostNames() 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.

See also QSocket.


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:

  • None - no information. This exists only so that QDns can have a default.
  • A - IPv4 addresses. By far the most common type.
  • Aaaa - Ipv6 addresses. So far mostly unused.
  • Mx - Mail eXchanger names. Used for mail delivery.
  • Srv - SeRVer names. Generic record type for finding servers. So far mostly unused.
  • Cname - canonical name. Maps from nicknames to the true name (the canonical name) for a host.
  • Ptr - name PoinTeR. Maps from IPv4 or IPv6 addresses to hostnames.
  • 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 both for the label and the search type.

QDns::QDns ( const QHostAddress & address, QDns::RecordType rr = Ptr )

Constructs a DNS query object that will return rr information about address. The label is set to the IN-ADDR.ARPA domain name. This is useful in combination with the Ptr record type (i.e. 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 emmitted.

rr defaults to Ptr, that maps addresses to hostnames.

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

Constructs a DNS query object that will return 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 emmitted.

rr defaults to A, IPv4 addresses.

QDns::~QDns () [virtual]

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.

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 lupinella.troll.no, and the search path for QDns is "trolltech.com", then the canonical name for all of "lupinella", "l", "lupinella.troll.no." and "l.trolltech.com" is "lupinella.troll.no.".

QStringList QDns::hostNames () const

Returns a list of host names if the record type is Ptr.

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().

QValueList<MailServer> QDns::mailServers () const

Returns a list of mail servers if the record type is Mx. The struct QDns::MailServer contains the following variables:

  • QString QDns::MailServer::name
  • Q_UINT16 QDns::MailServer::priority

QStringList QDns::qualifiedNames () const

Returns a list of the fully qualified names label() maps to.

QDns::RecordType QDns::recordType() const

Returns the record type of this query object.

See also setRecordType() and RecordType.

void QDns::resultsReady () [signal]

This signal is emitted when results are available for one of the qualifiedNames().

QValueList<Server> QDns::servers () const

Returns a list of servers if the record type is Srv. The struct QDns::Server contains the following variables:

  • QString QDns::Server::name
  • Q_UINT16 QDns::Server::priority
  • Q_UINT16 QDns::Server::weight
  • Q_UINT16 QDns::Server::port

void QDns::setLabel ( const QHostAddress & address ) [virtual]

Sets this query object to query for information about the address address. The label is set to the IN-ADDR.ARPA domain name. This is useful in combination with the Ptr record type (i.e. if you want to look up a hostname for a given address.

This does not change the recordType(), but its isWorking() most likely changes 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 emmitted.

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.

The DNS lookup is started the next time the application enters the event loop. When the result is found the signal resultsReady() is emmitted.

void QDns::setRecordType ( RecordType rr = A )

Sets this object to query for 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 emmitted.

See also RecordType.

QStringList QDns::texts () const

Returns a list of texts if the record type is Txt.


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


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 79
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

Les bases

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web