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  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Q3Dns Class Reference
[Qt3Support module]

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

#include <Q3Dns>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Note to Qt Desktop Light Edition users: This class is only available in the Qt Desktop Edition.

Inherits QObject.

Public Types

Public Functions

  • 28 public functions inherited from QObject

Signals

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The Q3Dns class provides asynchronous DNS lookups.

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.

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

The class is not straightforward to use (although it is much simpler than the native APIs); Q3Socket provides much easier to use TCP connection facilities. The aim of Q3Dns 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.)

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 Q3Dns 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 Q3Socket.


Member Type Documentation

enum Q3Dns::RecordType

This enum type defines the record types Q3Dns 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:

ConstantValueDescription
Q3Dns::None0No information. This exists only so that Q3Dns can have a default.
Q3Dns::A1IPv4 addresses. By far the most common type.
Q3Dns::Aaaa2IPv6 addresses. So far mostly unused.
Q3Dns::Mx3Mail eXchanger names. Used for mail delivery.
Q3Dns::Srv4SeRVer names. Generic record type for finding servers. So far mostly unused.
Q3Dns::Cname5Canonical names. Maps from nicknames to the true name (the canonical name) for a host.
Q3Dns::Ptr6name PoinTeRs. Maps from IPv4 or IPv6 addresses to hostnames.
Q3Dns::Txt7arbitrary TeXT for domains.

We expect that some support for the RFC 2535 extensions will be added in future versions.


Member Function Documentation

Q3Dns::Q3Dns ()

Constructs a DNS query object with invalid settings for both the label and the search type.

Q3Dns::Q3Dns ( 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.

Q3Dns::Q3Dns ( 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.

Q3Dns::~Q3Dns ()   [virtual]

Destroys the DNS query object and frees its allocated resources.

Q3ValueList<QHostAddress> Q3Dns::addresses () const

Returns a list of the addresses for this name if this Q3Dns object has a recordType() of Q3Dns::A or Q3Dns::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.

    Q3ValueList<QHostAddress> list = myDns.addresses();
    Q3ValueList<QHostAddress>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }

QString Q3Dns::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 Q3Dns is "trolltech.com", then the canonical name for all of "lillian", "l", "lillian.troll.no." and "l.trolltech.com" is "lillian.troll.no.".

QStringList Q3Dns::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 Q3Dns::isWorking () const

Returns true if Q3Dns is doing a lookup for this object (i.e. if it does not already have the necessary information); otherwise returns false.

Q3Dns emits the resultsReady() signal when the status changes to false.

QString Q3Dns::label () const

Returns the domain name for which this object returns information.

See also setLabel().

Q3ValueList<MailServer> Q3Dns::mailServers () const

Returns a list of mail servers if the record type is Mx. The class Q3Dns::MailServer contains the following public variables:

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    Q3ValueList<Q3Dns::MailServer> list = myDns.mailServers();
    Q3ValueList<Q3Dns::MailServer>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }

QStringList Q3Dns::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 Q3Dns::recordType () const

Returns the record type of this DNS query object.

See also setRecordType() and RecordType.

void Q3Dns::resultsReady ()   [signal]

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

Q3ValueList<Server> Q3Dns::servers () const

Returns a list of servers if the record type is Srv. The class Q3Dns::Server contains the following public variables:

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    Q3ValueList<Q3Dns::Server> list = myDns.servers();
    Q3ValueList<Q3Dns::Server>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }

void Q3Dns::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.

See also label().

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

This is an overloaded member function, provided for convenience.

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 Q3Dns::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() and RecordType.

QStringList Q3Dns::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;
    }

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 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. 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 4.1
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