Using QHostInfo to get host name from an IP
Hi all!
I am trying to get the host name from a IP inside my LAN using QHostInfo.
This is my code:
Code:
{
info.setAddresses();
qDebug() << "IP:" << info.hostName() << info.addresses();
return false;
}
The ip parameter is 192.168.1.91
But the result is:
IP: "192.168.1.91" (QHostAddress("192.168.1.91") )
The function does not returns the host name
Can anyone help me?
Thanks a lot.
Re: Using QHostInfo to get host name from an IP
fromName retrieve the IP address from name
Quote:
Looks up the IP address(es) for the given host name.
To get the host name from a IP address you need to use QHostInfo::lookupHost
EDIT: I made a test now and in my network also fromName returns the host name from the IP...
Re: Using QHostInfo to get host name from an IP
Yes, its in the QhostInfo documentation, but in my network it does not happen. Can Anyone help my please. Thanks a lot
Re: Using QHostInfo to get host name from an IP
What is the correct hostname?
Does the hostname correctly resolve to the address?
Cheers,
_