PDA

View Full Version : QHostInfo::lookupHost



matteo.ceruti
30th January 2012, 16:54
Hi,
I try to get the server name from the ip address
QHostInfo::lookupHost(sName,this, SLOT(lookedUp(QHostInfo)));

void ServiceServerWidget::lookedUp(const QHostInfo& host)
{
QString sRet = "";
bool bOk = true;
if (host.error() != QHostInfo::NoError)
{
QMessageBox::warning(this,tr("Warning"),tr("Error (%1) - %2").arg(host.error()).arg(host.errorString()));
lpLog->Error("ServiceServerWidget::lookedUp - Error %d %s",host.error(),host.errorString().toLatin1().data() );
bClose = false;
}
else
{
sRet = host.hostName();
}
...
The problem is: if IP address doesn't exists host.error() is QHostInfo::NoError and host.hostName() is the ip address.
How can I to control if the IP address is present in my network?

Thanks
Teo