Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_network_kernel_qdnslookup.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Jeremy Lainé <jeremy.laine@m4x.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5void MyObject::lookupServers()
6{
7 // Create a DNS lookup.
8 dns = new QDnsLookup(this);
9 connect(dns, &QDnsLookup::finished, this, &MyObject::handleServers);
10
11 // Find the XMPP servers for gmail.com
12 dns->setType(QDnsLookup::SRV);
13 dns->setName("_xmpp-client._tcp.gmail.com");
14 dns->lookup();
15}
17
18
20void MyObject::handleServers()
21{
22 // Check the lookup succeeded.
23 if (dns->error() != QDnsLookup::NoError) {
24 qWarning("DNS lookup failed");
25 dns->deleteLater();
26 return;
27 }
28
29 // Handle the results.
30 const auto records = dns->serviceRecords();
31 for (const QDnsServiceRecord &record : records) {
32 ...
33 }
34 dns->deleteLater();
35}
The QDnsLookup class represents a DNS lookup.
Definition qdnslookup.h:217
void finished()
This signal is emitted when the reply has finished processing.
The QDnsServiceRecord class stores information about a DNS SRV record.
Definition qdnslookup.h:98
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
#define qWarning
Definition qlogging.h:166
MyRecord record(int row) const
[0]