Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Some details of using QHostInfo::lookupHost
Mihan last edited by Mihan
I want to know how to check IP or DNS I set is ok. But I have some questions about
- If I set
QHostInfo::lookupHost("192.168.1.1",this, SLOT(receiver()), does it run continuously or just check once?
- If I set as follows ,will they interfere each other?
QHostInfo::lookupHost("192.168.1.1",this, SLOT(receiver1()); QHostInfo::lookupHost("192.168.1.2",this, SLOT(receiver2());
- How about check DNS is ok if in local area network?
- If I set
AFAIK, it will search once. It would not make sense to spam a DNS with the same query continuously.
No, they will not interfere. Note that the order in which you will ge the results is not guaranteed. See the method documentation.
I'm not sure I'm following you on that one.
Mihan last edited by
Normally, If I close the DHCP, I must set IP, gateway, netmask and DNS so that machine can go online, rigth?
So The third question is that if the IP is rigth but the DNS is wrong, can it detect?
IP: 192.168.1.1 (√)
DNS: 18.104.22.168 (not exist)
then I use
QHostInfo::lookupHost("22.214.171.124",this, SLOT(receiver2()), can it return the error.
BTY, If I want to make a real time check for the local area network, must I make a timer to run this function? Or you can give me some suggest, thank you.
If you don't have a DNS, you won't be able to have name resolution so you'll have to use only IP addresses to access resources you are interested in.
QHostInfo has an error method.
Pablo J. Rogina last edited by
then I use QHostInfo::lookupHost("126.96.36.199",this, SLOT(receiver2()), can it return the error.
Have you checked the code snippet from QHostInfo::lookupHost() documentation?
You have an example there how to check for error...