summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-04-06 07:50:13 +0200
committerOliver Wolff <oliver.wolff@qt.io>2017-04-10 05:20:16 +0000
commit13bb46bc3ad5e43a77fe2bcdacf9246a23983ce1 (patch)
tree10773ea141eea64773fbb3733f74520570428863 /src
parent3ded791062263a5c0df42bf8a6d5d0d8e351ea72 (diff)
winrt: Use hostnames for socket connections
Using IP addresses does not work for every use case on WinRT. The workaround that is in place for VPN connections uses the host name directly but has the disadvantage that it: 1) does a host lookup nevertheless and ends up using the host name afterwards. 2) needs a set environment variable to be activated. Instead of doing a host lookup we now use the same approach that is used if a proxy with the HostNameLookupCapability is present. In this case the lookup is skipped and the direction is made using the hostname. The big advantage of hostname over ip addresses on WinRt is, that Windows handles everything related to lookup and proxies (it uses the system proxy in this case), so we do not have to take care of that. As the WinRT backend falls back to the "connectToHostByName" in any case no further adaptions are needed. QT_WINRT_USE_THREAD_NETWORK_CONTEXT cannot be completely removed though as the creation of the network context should not be done unconditionally. This change partially reverts e9fa435652ef064515bd5c04c0b5e5c4a30ebca4 Task-number: QTBUG-59989 Change-Id: I5dc7481b7499192641470b4b5a6642509a4b4f38 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/network/socket/qabstractsocket.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 7ecbf35489..9cb6c4be57 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -943,7 +943,9 @@ void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port)
// DefaultProxy here will raise an error
proxyInUse = QNetworkProxy();
}
+#endif // !QT_NO_NETWORKPROXY
+#if !defined(QT_NO_NETWORKPROXY) || defined(Q_OS_WINRT)
/*!
\internal
@@ -981,7 +983,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host)
emit q->stateChanged(state);
}
-#endif
+#endif // !QT_NO_NETWORKPROXY || Q_OS_WINRT
/*! \internal
@@ -1113,10 +1115,6 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
// (localhost address on BSD or any UDP connect), emit
// connected() and return.
if (
-#if defined(Q_OS_WINRT) && _MSC_VER >= 1900
- !qEnvironmentVariableIsEmpty("QT_WINRT_USE_THREAD_NETWORK_CONTEXT") ?
- socketEngine->connectToHostByName(hostName, port) :
-#endif
socketEngine->connectToHost(host, port)) {
//_q_testConnection();
fetchConnectionParameters();
@@ -1712,6 +1710,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
QIODevice::open(openMode);
d->readChannelCount = d->writeChannelCount = 0;
+#ifndef Q_OS_WINRT
d->state = HostLookupState;
emit stateChanged(d->state);
@@ -1749,6 +1748,10 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
(d->state == ConnectingState || d->state == HostLookupState)
? " (connection in progress)" : "");
#endif
+#else // !Q_OS_WINRT
+ // On WinRT we should always connect by name. Lookup and proxy handling are done by the API.
+ d->startConnectingByName(hostName);
+#endif
}
/*! \overload