summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qabstractsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r--src/network/socket/qabstractsocket.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 275c436..95721ee 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -172,6 +172,10 @@
This signal is emitted after connectToHost() has been called and
the host lookup has succeeded.
+ \note Since Qt 4.6.3 QAbstractSocket may emit hostFound()
+ directly from the connectToHost() call since a DNS result could have been
+ cached.
+
\sa connected()
*/
@@ -181,6 +185,10 @@
This signal is emitted after connectToHost() has been called and
a connection has been successfully established.
+ \note On some operating systems the connected() signal may
+ be directly emitted from the connectToHost() call for connections
+ to the localhost.
+
\sa connectToHost(), disconnected()
*/
@@ -354,6 +362,8 @@
#include "qabstractsocket.h"
#include "qabstractsocket_p.h"
+#include "private/qhostinfo_p.h"
+
#include <qabstracteventdispatcher.h>
#include <qdatetime.h>
#include <qhostaddress.h>
@@ -1369,8 +1379,20 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
return;
#endif
} else {
- if (d->threadData->eventDispatcher)
- d->hostLookupId = QHostInfo::lookupHost(hostName, this, SLOT(_q_startConnecting(QHostInfo)));
+ if (d->threadData->eventDispatcher) {
+ // this internal API for QHostInfo either immediatly gives us the desired
+ // QHostInfo from cache or later calls the _q_startConnecting slot.
+ bool immediateResultValid = false;
+ QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
+ this,
+ SLOT(_q_startConnecting(QHostInfo)),
+ &immediateResultValid,
+ &d->hostLookupId);
+ if (immediateResultValid) {
+ d->hostLookupId = -1;
+ d->_q_startConnecting(hostInfo);
+ }
+ }
}
#if defined(QABSTRACTSOCKET_DEBUG)