How to get ip address programactically on Debian based system?
Posted
by gc
on Stack Overflow
See other posts from Stack Overflow
or by gc
Published on 2009-03-31T13:38:51Z
Indexed on
2010/04/26
22:33 UTC
Read the original article
Hit count: 208
I'm trying to retrieve the ip address of the local machine in my program. The OS running is Ubuntu 8.10. I tried using gethostname() and gethostbyname to do it. All I can get is 127.0.1.1. I learned that it seems to be a Debian thing:
This thread explained it.
The content of my /etc/hosts file is also:
127.0.0.1 localhost
127.0.1.1 mymachine
In this case, is there any other way to programactically (prefer C or C++) to get the ip address without modifying the system file on the machine? Thanks in advance.
g.c.
© Stack Overflow or respective owner