Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get ip from computer name?

How to get ip from computer name?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 3 Posters 0 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
    MANISH RASTOGI
    wrote on last edited by
    #1

    Hi All, I am using gethostbyname function to get ip from name. It works fine if ip is defined. But if 'Obtain ip address automatically' settings is on, this function gives some different ip. Any help please. Thanks

    S D 2 Replies Last reply
    0
    • M MANISH RASTOGI

      Hi All, I am using gethostbyname function to get ip from name. It works fine if ip is defined. But if 'Obtain ip address automatically' settings is on, this function gives some different ip. Any help please. Thanks

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      manish rastogi wrote:

      using gethostbyname function to get ip from name

      The IP of what computer - your computer? A remote computer?

      manish rastogi wrote:

      if 'Obtain ip address automatically' settings is on, this function gives some different ip

      Where is 'Obtain ip address automatically' set - on your computer? And 'different ip' for what - your computer, a remote computer?

      M 1 Reply Last reply
      0
      • M MANISH RASTOGI

        Hi All, I am using gethostbyname function to get ip from name. It works fine if ip is defined. But if 'Obtain ip address automatically' settings is on, this function gives some different ip. Any help please. Thanks

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        manish rastogi wrote:

        But if 'Obtain ip address automatically' settings is on, this function gives some different ip.

        Which is the whole essence of DHCP. The gethostbyname() function does not care how your computer obtained its IP address.

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        1 Reply Last reply
        0
        • S Stuart Dootson

          manish rastogi wrote:

          using gethostbyname function to get ip from name

          The IP of what computer - your computer? A remote computer?

          manish rastogi wrote:

          if 'Obtain ip address automatically' settings is on, this function gives some different ip

          Where is 'Obtain ip address automatically' set - on your computer? And 'different ip' for what - your computer, a remote computer?

          M Offline
          M Offline
          MANISH RASTOGI
          wrote on last edited by
          #4

          'Obtain ip address automatically' set - on remote computer, got different ip. 'Prefered DSN Server' settings had wrong value. After changing it got correct ip.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups