468,512 Members | 1,406 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Getting local IP address

Hi,

I'm trying to figure how I can programatically get the the IP addresses of all interfaces. That is, I'm in a Linux machine, and I want a C program to find out the IP adderess that the machine has (like I can get with /sbin/ifconfig). One way I'm aware of, is to parse /proc/net/if_inet6, but this seems to be connected to IPv6, I want to support also IPv4. What other ways exists to find this info ?

thanks in advance,
Megatron
Jan 19 '08 #1
1 3784
gpraghuram
1,275 Expert 1GB
Hi,

I'm trying to figure how I can programatically get the the IP addresses of all interfaces. That is, I'm in a Linux machine, and I want a C program to find out the IP adderess that the machine has (like I can get with /sbin/ifconfig). One way I'm aware of, is to parse /proc/net/if_inet6, but this seems to be connected to IPv6, I want to support also IPv4. What other ways exists to find this info ?

thanks in advance,
Megatron

Trty to do more research on gethostinfo and gethostbyname....and similar functions.
One of the functions will help u to achieve what u want

Raghuram
Jan 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.