Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhostinfo_win.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <winsock2.h>
6
7#include "qhostinfo_p.h"
8#include <ws2tcpip.h>
9#include <private/qsystemlibrary_p.h>
10#include <qmutex.h>
11#include <qbasicatomic.h>
12#include <qurl.h>
13
15
16//#define QHOSTINFO_DEBUG
17
18//###
19#ifndef NI_MAXHOST // already defined to 1025 in ws2tcpip.h?
20#define NI_MAXHOST 1024
21#endif
22
23QHostInfo QHostInfoAgent::fromName(const QString &hostName)
24{
25 QSysInfo::machineHostName(); // this initializes ws2_32.dll
26
27 QHostInfo results;
28
29#if defined(QHOSTINFO_DEBUG)
30 qDebug("QHostInfoAgent::fromName(%s) looking up...",
31 hostName.toLatin1().constData());
32#endif
33
34 QHostAddress address;
35 if (address.setAddress(hostName))
36 return reverseLookup(address);
37
38 return lookup(hostName);
39}
40
41// QString QHostInfo::localDomainName() defined in qnetworkinterface_win.cpp
42
43QT_END_NAMESPACE