getting IP addresses of network interfaces on Linux box

HI all, I need to know is there anyway I can get the IP addresses of Network interfaces (i.e. physical and logical) on my Linux box through socket APIs?

Thanks, B

Reply to
bizhan.gholikhamseh
Loading thread data ...

There are IOCTL's you can call on a socket fd, something like this, from the top of my head:

int fd; strict ifreq ifr; struct sockaddr_sin *sa; fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); strcpy(ifr.ifr_name, ifname); /* Don't use strcpy */ ioctl(fd, SIOGCIFADDR, &ifr); sa = (struct sockaddr_in *)(ifr.ifr_addr);

--
:wq
^X^Cy^K^X^C^C^C^C
Reply to
Ico

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.