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. Can't resolve hostname from ip adress QHostInfo::fromName(IP)

Can't resolve hostname from ip adress QHostInfo::fromName(IP)

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.3k Views
  • 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.
  • A Offline
    A Offline
    Antrouille
    wrote on 15 Jun 2017, 14:53 last edited by
    #1

    Hello everyone,
    I try to make a really simple program who return the host name on a network from it ip address.
    Unfortunately every ip I tried return only the ip.

    here is the code :
    QHostInfo HI = QHostInfo::fromName("192.168.1.122"); // this PC hostname is "deian8-trb"
    qDebug() << HI.hostName(); // display "192.168.2.122"

    I try with lookupHost but the result are the same.

    Did someone have an idea of the problem ?

    K 1 Reply Last reply 15 Jun 2017, 15:52
    0
    • A Antrouille
      15 Jun 2017, 14:53

      Hello everyone,
      I try to make a really simple program who return the host name on a network from it ip address.
      Unfortunately every ip I tried return only the ip.

      here is the code :
      QHostInfo HI = QHostInfo::fromName("192.168.1.122"); // this PC hostname is "deian8-trb"
      qDebug() << HI.hostName(); // display "192.168.2.122"

      I try with lookupHost but the result are the same.

      Did someone have an idea of the problem ?

      K Offline
      K Offline
      koahnig
      wrote on 15 Jun 2017, 15:52 last edited by
      #2

      @Antrouille

      Did you try localHostName?

      Vote the answer(s) that helped you to solve your issue(s)

      A 1 Reply Last reply 16 Jun 2017, 12:16
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 15 Jun 2017, 21:40 last edited by
        #3

        Hi,

        From your description it looks like you should be using lookupHost.

        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
        0
        • K koahnig
          15 Jun 2017, 15:52

          @Antrouille

          Did you try localHostName?

          A Offline
          A Offline
          Antrouille
          wrote on 16 Jun 2017, 12:16 last edited by
          #4

          @koahnig
          For my local PC, I have no problem with fromName(IP) or localHostName.
          But with any other PC than mine, I only get the IP.

          @SGaist
          Yes, I already tried lookuphost but with the same result.

          Thanks for your help.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            achard.ju
            wrote on 16 Jun 2017, 12:39 last edited by
            #5

            Do you have an upToDate host file on your computer ?
            On Windows 7

            %systemroot%\system32\drivers\etc\host
            

            Or On Linux Systems

            /etc/hosts
            

            If not, i think that's the DNS in charge of name resolution. So the DNS have to provide name resolution for your local network.

            A 1 Reply Last reply 16 Jun 2017, 12:53
            0
            • A achard.ju
              16 Jun 2017, 12:39

              Do you have an upToDate host file on your computer ?
              On Windows 7

              %systemroot%\system32\drivers\etc\host
              

              Or On Linux Systems

              /etc/hosts
              

              If not, i think that's the DNS in charge of name resolution. So the DNS have to provide name resolution for your local network.

              A Offline
              A Offline
              Antrouille
              wrote on 16 Jun 2017, 12:53 last edited by
              #6

              @achard.ju

              Thanks, I've check the linux host file, it seem to be ok (I test with a windows and linux machine).
              But still the same :(

              Now I need to see the IT guy for the DNS.

              Thanks for your help.

              1 Reply Last reply
              0

              2/6

              15 Jun 2017, 15:52

              topic:navigator.unread, 4
              • Login

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