Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-27-2006, 06:18 PM   #1
Registered: Dec 2005
Posts: 83

Rep: Reputation: 15
find ip address of my computer in C/C++

Hello Everyone,

How can I get my machine IP address programmatically using C++ or C. Is there any function that can give me the IP or some info with it and I parse the IP from it?

I was thinking to open one of the files that contain the ip address and parse it out, but it looked like there are something simpler to get the ip.

Thanks in advance,
Alaa G
Old 04-27-2006, 07:51 PM   #2
Registered: Apr 2006
Location: Pittsburgh
Distribution: Debian Sid AMD64
Posts: 296

Rep: Reputation: 30
You can use gethostbyname() to do this.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find the ip address of a computer that is connected to LAN gajaykrishnan Linux - Networking 7 12-03-2010 06:38 AM
Why Scourge (2nd computer) isn't getting ip address from Misery (1st computer) dhcp? pslave Linux - Networking 2 04-09-2006 06:58 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 08:55 AM
how to find my computer address? mfrangos79 Linux - Newbie 9 11-09-2005 06:20 PM
How to find IP address of a machine if I know their MAC Address dysenteryduke Linux - Networking 13 09-12-2005 11:21 AM

All times are GMT -5. The time now is 03:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration