Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Some details of using QHostInfo::lookupHost
Forum Updated to NodeBB v4.3 + New Features

Some details of using QHostInfo::lookupHost

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 738 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by Mihan
    #1

    Hi!
    I want to know how to check IP or DNS I set is ok. But I have some questions about lookupHost().

    1. If I set QHostInfo::lookupHost("192.168.1.1",this, SLOT(receiver()) , does it run continuously or just check once?
    2. 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());
    
    1. How about check DNS is ok if in local area network?
      e.g. QHostInfo::lookupHost("8.8.8.8",this, SLOT(receiver2()).

    Regards.
    Mihan

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      1. AFAIK, it will search once. It would not make sense to spam a DNS with the same query continuously.

      2. No, they will not interfere. Note that the order in which you will ge the results is not guaranteed. See the method documentation.

      3. I'm not sure I'm following you on that one.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      MihanM 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        1. AFAIK, it will search once. It would not make sense to spam a DNS with the same query continuously.

        2. No, they will not interfere. Note that the order in which you will ge the results is not guaranteed. See the method documentation.

        3. I'm not sure I'm following you on that one.

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by
        #3

        Thanks @SGaist
        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?
        e.g.
        IP: 192.168.1.1 (√)
        DNS: 8.8.7.8 (not exist)
        then I use QHostInfo::lookupHost("8.8.7.8",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.

        Regards
        Mihan

        Pablo J. RoginaP 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • MihanM Mihan

            Thanks @SGaist
            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?
            e.g.
            IP: 192.168.1.1 (√)
            DNS: 8.8.7.8 (not exist)
            then I use QHostInfo::lookupHost("8.8.7.8",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.

            Regards
            Mihan

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @Mihan said in Some details of using QHostInfo::lookupHost:

            then I use QHostInfo::lookupHost("8.8.7.8",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...

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved