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 do i get my comp's ip ?

How do i get my comp's ip ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 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.
  • C Offline
    C Offline
    Chernobog1
    wrote on last edited by
    #1

    Hi, is there any function which tells me what ip has the machine ? (i dont mean 127.0.0.1 ;)). Thanks

    B 1 Reply Last reply
    0
    • C Chernobog1

      Hi, is there any function which tells me what ip has the machine ? (i dont mean 127.0.0.1 ;)). Thanks

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #2

      GetMyIp(void) const { // Don't forget to initialize the sockets and stuff! char locn[255]; CString ip; if (SOCKET_ERROR != gethostname(locn, 255)) ip = inet_ntoa(*(struct in_addr *)*gethostbyname(locn)->h_addr_list); return ip; } Bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

      C 1 Reply Last reply
      0
      • B bryce

        GetMyIp(void) const { // Don't forget to initialize the sockets and stuff! char locn[255]; CString ip; if (SOCKET_ERROR != gethostname(locn, 255)) ip = inet_ntoa(*(struct in_addr *)*gethostbyname(locn)->h_addr_list); return ip; } Bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

        C Offline
        C Offline
        Chernobog1
        wrote on last edited by
        #3

        That was pretty fast reply :) Thanks

        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