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  · 

QDnsLookup Class

The QDnsLookup class represents a DNS lookup. More...

 #include <QDnsLookup>

Inherits: QObject.

This class was introduced in Qt 5.0.

Public Types

enum Error { NoError, ResolverError, OperationCancelledError, InvalidRequestError, ..., NotFoundError }
enum Type { A, AAAA, ANY, CNAME, ..., TXT }

Properties

  • 1 property inherited from QObject

Public Functions

QDnsLookup(QObject * parent = 0)
QDnsLookup(Type type, const QString & name, QObject * parent = 0)
~QDnsLookup()
QList<QDnsDomainNameRecord> canonicalNameRecords() const
Error error() const
QString errorString() const
QList<QDnsHostAddressRecord> hostAddressRecords() const
bool isFinished() const
QList<QDnsMailExchangeRecord> mailExchangeRecords() const
QString name() const
QList<QDnsDomainNameRecord> nameServerRecords() const
QList<QDnsDomainNameRecord> pointerRecords() const
QList<QDnsServiceRecord> serviceRecords() const
void setName(const QString & name)
void setType(QDnsLookup::Type)
QList<QDnsTextRecord> textRecords() const
Type type() const
  • 31 public functions inherited from QObject

Public Slots

void abort()
void lookup()
  • 1 public slot inherited from QObject

Signals

void finished()
void nameChanged(const QString & name)
void typeChanged(Type type)

Additional Inherited Members

  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QDnsLookup class represents a DNS lookup.

QDnsLookup uses the mechanisms provided by the operating system to perform DNS lookups. To perform a lookup you need to specify a name and type then invoke the lookup() slot. The finished() signal will be emitted upon completion.

For example, you can determine which servers an XMPP chat client should connect to for a given domain with:

 void MyObject::lookupServers()
 {
     // Create a DNS lookup.
     dns = new QDnsLookup(this);
     connect(dns, SIGNAL(finished()),
             this, SLOT(handleServers()));

     // Find the XMPP servers for gmail.com
     dns->setType(QDnsLookup::SRV);
     dns->setName("_xmpp-client._tcp.gmail.com");
     dns->lookup();
 }

Once the request finishes you can handle the results with:

 void MyObject::handleServers()
 {
     // Check the lookup succeeded.
     if (dns->error() != QDnsLookup::NoError) {
         qWarning("DNS lookup failed");
         dns->deleteLater();
         return;
     }

     // Handle the results.
     foreach (const QDnsServiceRecord &record, dns->serviceRecords()) {
         ...
     }
     dns->deleteLater();
 }

Note: If you simply want to find the IP address(es) associated with a host name, or the host name associated with an IP address you should use QHostInfo instead.

Member Type Documentation

enum QDnsLookup::Error

Indicates all possible error conditions found during the processing of the DNS lookup.

ConstantValueDescription
QDnsLookup::NoError0no error condition.
QDnsLookup::ResolverError1there was an error initializing the system's DNS resolver.
QDnsLookup::OperationCancelledError2the lookup was aborted using the abort() method.
QDnsLookup::InvalidRequestError3the requested DNS lookup was invalid.
QDnsLookup::InvalidReplyError4the reply returned by the server was invalid.
QDnsLookup::ServerFailureError5the server encountered an internal failure while processing the request (SERVFAIL).
QDnsLookup::ServerRefusedError6the server refused to process the request for security or policy reasons (REFUSED).
QDnsLookup::NotFoundError7the requested domain name does not exist (NXDOMAIN).

enum QDnsLookup::Type

Indicates the type of DNS lookup that was performed.

ConstantValueDescription
QDnsLookup::A1IPv4 address records.
QDnsLookup::AAAA28IPv6 address records.
QDnsLookup::ANY255any records.
QDnsLookup::CNAME5canonical name records.
QDnsLookup::MX15mail exchange records.
QDnsLookup::NS2name server records.
QDnsLookup::PTR12pointer records.
QDnsLookup::SRV33service records.
QDnsLookup::TXT16text records.

Property Documentation

error : const Error

This property holds the type of error that occurred if the DNS lookup failed, or NoError.

Access functions:

Error error() const

Notifier signal:

void finished()

errorString : const QString

This property holds a human-readable description of the error if the DNS lookup failed.

Access functions:

QString errorString() const

Notifier signal:

void finished()

name : QString

This property holds the name to lookup.

Note: The name will be encoded using IDNA, which means it's unsuitable for querying SRV records compatible with the DNS-SD specification.

Access functions:

QString name() const
void setName(const QString & name)

Notifier signal:

void nameChanged(const QString & name)

type : Type

This property holds the type of DNS lookup.

Access functions:

Type type() const
void setType(QDnsLookup::Type)

Notifier signal:

void typeChanged(Type type)

Member Function Documentation

QDnsLookup::QDnsLookup(QObject * parent = 0)

Constructs a QDnsLookup object and sets parent as the parent object.

The type property will default to QDnsLookup::A.

QDnsLookup::QDnsLookup(Type type, const QString & name, QObject * parent = 0)

Constructs a QDnsLookup object for the given type and name and sets parent as the parent object.

QDnsLookup::~QDnsLookup()

Destroys the QDnsLookup object.

It is safe to delete a QDnsLookup object even if it is not finished, you will simply never receive its results.

void QDnsLookup::abort() [slot]

Aborts the DNS lookup operation.

If the lookup is already finished, does nothing.

QList<QDnsDomainNameRecord> QDnsLookup::canonicalNameRecords() const

Returns the list of canonical name records associated with this lookup.

QList<QDnsHostAddressRecord> QDnsLookup::hostAddressRecords() const

Returns the list of host address records associated with this lookup.

bool QDnsLookup::isFinished() const

Returns whether the reply has finished or was aborted.

void QDnsLookup::lookup() [slot]

Performs the DNS lookup.

The finished() signal is emitted upon completion.

QList<QDnsMailExchangeRecord> QDnsLookup::mailExchangeRecords() const

Returns the list of mail exchange records associated with this lookup.

The records are sorted according to RFC 5321, so if you use them to connect to servers, you should try them in the order they are listed.

QList<QDnsDomainNameRecord> QDnsLookup::nameServerRecords() const

Returns the list of name server records associated with this lookup.

QList<QDnsDomainNameRecord> QDnsLookup::pointerRecords() const

Returns the list of pointer records associated with this lookup.

QList<QDnsServiceRecord> QDnsLookup::serviceRecords() const

Returns the list of service records associated with this lookup.

The records are sorted according to RFC 2782, so if you use them to connect to servers, you should try them in the order they are listed.

QList<QDnsTextRecord> QDnsLookup::textRecords() const

Returns the list of text records associated with this lookup.

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 5.0-snapshot
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