Aiee :) Hello! On Fri, Nov 03, 2000 at 12:35:58PM -0500, Christopher Friesen wrote: > I would like to get the IP address of one of the interfaces of the > machine that I'm currently on from within some C++ code. It looks like > I should be able to do this by doing an > > ioctl(atoi(fd, SIOCGIFADDR, &ifr) > > with the interface name set in the appropriate field in ifr, but I'm not > sure how I should be getting the proper value for fd. I would You have to issue the ioctl call on a so-called `dummy' socket. Just open a simple socket, e.g. fd = socket(AF_INET, SOCK_DGRAM, 0); (check for error) ioctl(fd, SIOCGIFADDR, &ifr); (ifr.ifr_name holds the iface name) (I don't know what you'd like to do with that atoi :)) > appreciate some help on this, or if there is a better way then I'd love > to hear it. A better way should be using (open/create) a netlink socket. Unfortunatly I don't know how to do this ;) (I have to read and learn netlink `programming'). That said I'm not 100% sure about this (netlink stuff) :) By the way, if someone could post some `netlink' examples, links, and so on :) thanks. > Thanks, > > Chris > > > -- > Chris Friesen | MailStop: 043/33/F10 > Nortel Networks | work: (613) 765-0557 > 3500 Carling Avenue | fax: (613) 765-2986 > Nepean, ON K2H 8E9 Canada | email: cfriesen@nortelnetworks.com > - > : send the line "unsubscribe linux-net" in > the body of a message to majordomo@vger.kernel.org Hope this helps. bye bye -- gg sullivan -- Lorenzo Cavallaro `Gigi Sullivan' <sullivan@sikurezza.org> LibRNet Project Home Page: http://www.sikurezza.org/sullivan LibRNet Mailing List: librnet-subscribe@egroups.com Until I loved, life had no beauty; I did not know I lived until I had loved. (Theodor Korner) - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org