Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
4
//! [0]
5
void
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
}
16
//! [0]
17
18
19
//! [1]
20
void
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
}
36
//! [1]
qtbase
src
network
doc
snippets
code
src_network_kernel_qdnslookup.cpp
Generated on
for Qt by
1.18.0