Thread: how to get host IP using C ?

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    how to get host IP using C ?

    hi all :
    how to get host ip under Linux ??
    Last edited by pinky; 10-15-2009 at 07:16 PM.

  2. #2
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    google it?

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Which operating system are you using? It's platform-dependent. This function is pretty ubiquitous: man gethostbyname(3)
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    6
    Quote Originally Posted by itsme86 View Post
    Which operating system are you using? It's platform-dependent. This function is pretty ubiquitous: man gethostbyname(3)
    My os is ubuntu

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    It depends on what you want. To get the actual network IP address you can use such functions, but to get the global IP address (that is, the WAN IP address and not the LAN IP address) you need to have another computer tell you what your IP address is.

    You could use a site like getmyipaddress.com or similar... Or your custom clients can help the server to get its IP address. Although both solutions might be unsafe...

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    As Epy said, Google it !
    In particular for such basic things, asked thousands of times for 20 years...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. strstr problem
    By Kempelen in forum C Programming
    Replies: 2
    Last Post: 09-08-2009, 03:46 AM
  3. hidding the host ip address
    By xddxogm3 in forum Tech Board
    Replies: 4
    Last Post: 04-25-2006, 08:50 PM
  4. Replies: 9
    Last Post: 11-13-2001, 11:43 AM