QAbstractSocket::waitForConnected check if host name is an IP address

If the current host name is an ip address we can create the QHostInfo
directly instead of performing a reverse lookup.

Task-number: QTBUG-18881
Change-Id: If239481e455f4f7fb74d978f685dc5d8e9f22c0a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
This commit is contained in:
Martin Petersson 2012-03-30 13:07:33 +02:00 committed by Qt by Nokia
parent a84b42e619
commit 0e6361d316

View File

@ -1984,8 +1984,17 @@ bool QAbstractSocket::waitForConnected(int msecs)
d->_q_startConnecting(QHostInfoPrivate::fromName(d->hostName, networkSession));
} else
#endif
{
QHostAddress temp;
if (temp.setAddress(d->hostName)) {
QHostInfo info;
info.setAddresses(QList<QHostAddress>() << temp);
d->_q_startConnecting(info);
} else {
d->_q_startConnecting(QHostInfo::fromName(d->hostName));
}
}
}
if (state() == UnconnectedState)
return false; // connect not im progress anymore!