Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!rutgers!columbia!cunixc!micky From: micky@cunixc.cc.columbia.edu (Micky Liu) Newsgroups: comp.unix.wizards Subject: Re: Determining one's own IP address. Message-ID: <2450@cunixc.cc.columbia.edu> Date: 14 Dec 89 04:51:12 GMT References: <601@bmers58.UUCP> <4429@ur-cc.UUCP> <604@bmers58.UUCP> <5215@tekcrl.LABS.TEK.COM> <5229@tekcrl.LABS.TEK.COM> Reply-To: micky@cunixc.cc.columbia.edu (Micky Liu) Organization: Columbia University Lines: 36 I have to admit that I have not been following the whole story here, but if you are attempting to determine the IP address of a machine, then I think the correct method is to use an ioctl() call to request information on all of the connected network interfaces (since a machine can be multi-homed). The next step is to examine the list of interfaces returned and look for the IP address assigned to each physical network interface. I have only had experience with Sun's so this may be machine specific, but I think conceptually it should be the same on all Unix machines... The important structures are: struct ifconf ifc; struct ifreq *ifr; both of which I think can be found in /usr/include/net/if.h. The particular ioctl() call looks like: ioctl(socket,SIOCGIFCONF,(char*)&ifc) Then there will be a list of structures that can accesses with ifr = ifc.ifc_req; Much of this information can be found in the SunOS 4.x Network Programmer's Manual, Chapter 9 -- An Advanced Socket-Based Interprocess Communications Tutorial. The example they use will find broadcast addresses for each network interface, but the method can be readily adapted to find the IP address of each interface. Good Luck! Micky internet: micky@cunixc.cc.columbia.edu usenet: ...!rutgers!columbia!cunixc!micky bitnet: micky@cunixc.bitnet