Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] An IP address is connected or not
Qt 6.12 LTS is out! See what's new in the release blog

[Solved] An IP address is connected or not

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.5k Views 1 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.
  • M Offline
    M Offline
    MohammadReza
    wrote on last edited by
    #1

    Hi friend.

    I want to find all ip addresses that are connected (in LAN).
    I used lookupHost() function explained in this link:
    http://qt-project.org/doc/qt-4.8/qhostinfo.html#lookupHost

    But my application says "Found address:" for all ip addresses!
    I glad to hear your ideas.

    Thanks a lot.
    Ya Ali.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, you can use ping 192.168.1.1, 192.168.1.2 and so on but it's not 100% because of firewalls, or for a printer or an iPhone because they're sleeping (i.e. an iPhone only answers to ping when the display is lit, unless it has power connected).

      Same as for your other question, using the ARP protocol is probably best.
      Also you can download the nmap tool.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MohammadReza
        wrote on last edited by
        #3

        Hi again & thank a million. :)

        In the link that I`ve mentioned in my first post, There is an example.
        I replace the QHostInfo::HostNotFound instead of QHostInfo::NoError, but did not work.

        Your ideas about ping is very nice, but my applicaion have to be cross-platform with minimum changing of code.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Glad to help!
          About why QHostinfo::HostNotFound doesn't work, I think it works but only when you try a DNS name, like www.google.com. I.e. a number like 192.168.61.111 is always "found".

          About crossplatform: you can look at that network scanning utility I mentioned before "nmap":http://nmap.org/download.html it comes with source code.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MohammadReza
            wrote on last edited by
            #5

            QHostinfo::HostNotFound doesn’t work even for www.google.com.
            qDebuge results:
            Lookup failed: "Unknown error"

            You`re right. nmap is a good idea for cross-platform application.
            English language is not my main language. I dont know which phrase means thank you very very much. But I say thank you very very much. :)

            Solved!

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MohammadReza
              wrote on last edited by
              #6

              Hello again to all,
              I created a dll to find all online IP addresses and their MAC addresses in the LAN. Share with you:
              I wrote an article about this topic and posted in CodeProject:
              http://www.codeproject.com/Articles/798730/Finding-All-Online-IP-Addresses-Simple-Method

              1 Reply Last reply
              0

              • Login

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