170 \fn void QAbstractSocket::hostFound() |
170 \fn void QAbstractSocket::hostFound() |
171 |
171 |
172 This signal is emitted after connectToHost() has been called and |
172 This signal is emitted after connectToHost() has been called and |
173 the host lookup has succeeded. |
173 the host lookup has succeeded. |
174 |
174 |
|
175 \note Since Qt 4.6.3 QAbstractSocket may emit hostFound() |
|
176 directly from the connectToHost() call since a DNS result could have been |
|
177 cached. |
|
178 |
175 \sa connected() |
179 \sa connected() |
176 */ |
180 */ |
177 |
181 |
178 /*! |
182 /*! |
179 \fn void QAbstractSocket::connected() |
183 \fn void QAbstractSocket::connected() |
180 |
184 |
181 This signal is emitted after connectToHost() has been called and |
185 This signal is emitted after connectToHost() has been called and |
182 a connection has been successfully established. |
186 a connection has been successfully established. |
|
187 |
|
188 \note On some operating systems the connected() signal may |
|
189 be directly emitted from the connectToHost() call for connections |
|
190 to the localhost. |
183 |
191 |
184 \sa connectToHost(), disconnected() |
192 \sa connectToHost(), disconnected() |
185 */ |
193 */ |
186 |
194 |
187 /*! |
195 /*! |
352 */ |
360 */ |
353 |
361 |
354 #include "qabstractsocket.h" |
362 #include "qabstractsocket.h" |
355 #include "qabstractsocket_p.h" |
363 #include "qabstractsocket_p.h" |
356 |
364 |
|
365 #include "private/qhostinfo_p.h" |
|
366 |
357 #include <qabstracteventdispatcher.h> |
367 #include <qabstracteventdispatcher.h> |
358 #include <qdatetime.h> |
368 #include <qdatetime.h> |
359 #include <qhostaddress.h> |
369 #include <qhostaddress.h> |
360 #include <qhostinfo.h> |
370 #include <qhostinfo.h> |
361 #include <qmetaobject.h> |
371 #include <qmetaobject.h> |
1367 // the proxy supports connection by name, so use it |
1377 // the proxy supports connection by name, so use it |
1368 d->startConnectingByName(hostName); |
1378 d->startConnectingByName(hostName); |
1369 return; |
1379 return; |
1370 #endif |
1380 #endif |
1371 } else { |
1381 } else { |
1372 if (d->threadData->eventDispatcher) |
1382 if (d->threadData->eventDispatcher) { |
1373 d->hostLookupId = QHostInfo::lookupHost(hostName, this, SLOT(_q_startConnecting(QHostInfo))); |
1383 // this internal API for QHostInfo either immediatly gives us the desired |
|
1384 // QHostInfo from cache or later calls the _q_startConnecting slot. |
|
1385 bool immediateResultValid = false; |
|
1386 QHostInfo hostInfo = qt_qhostinfo_lookup(hostName, |
|
1387 this, |
|
1388 SLOT(_q_startConnecting(QHostInfo)), |
|
1389 &immediateResultValid, |
|
1390 &d->hostLookupId); |
|
1391 if (immediateResultValid) { |
|
1392 d->hostLookupId = -1; |
|
1393 d->_q_startConnecting(hostInfo); |
|
1394 } |
|
1395 } |
1374 } |
1396 } |
1375 |
1397 |
1376 #if defined(QABSTRACTSOCKET_DEBUG) |
1398 #if defined(QABSTRACTSOCKET_DEBUG) |
1377 qDebug("QAbstractSocket::connectToHost(\"%s\", %i) == %s%s", hostName.toLatin1().constData(), port, |
1399 qDebug("QAbstractSocket::connectToHost(\"%s\", %i) == %s%s", hostName.toLatin1().constData(), port, |
1378 (d->state == ConnectedState) ? "true" : "false", |
1400 (d->state == ConnectedState) ? "true" : "false", |