From owner-freebsd-net Thu Jul 18 9:50: 8 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3478D37B400 for ; Thu, 18 Jul 2002 09:50:05 -0700 (PDT) Received: from hotmail.com (f94.law9.hotmail.com [64.4.9.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id F233243E5E for ; Thu, 18 Jul 2002 09:50:04 -0700 (PDT) (envelope-from freebsdfan@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Jul 2002 09:50:04 -0700 Received: from 68.4.57.222 by lw9fd.law9.hotmail.msn.com with HTTP; Thu, 18 Jul 2002 16:50:04 GMT X-Originating-IP: [68.4.57.222] From: "Chuck T." To: ertr1013@student.uu.se Cc: net@freebsd.org Subject: Re: programatically list all local IP addresses ? Date: Thu, 18 Jul 2002 09:50:04 -0700 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 18 Jul 2002 16:50:04.0815 (UTC) FILETIME=[2A77E1F0:01C22E7B] Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Use gethostname()/gethostbyname() (or gethostbyaddr()) and then look >through the 'h_addr_list' array in the 'struct hostent' returned by >gethostbyname(). That should contain all the network addresses that >were found for the given host. That doesn't work when the lookup matches an entry in /etc/hosts, only the *first* address is returned even if there are multiple entries. That was my first attempt. The machine that was returning 127.0.0.1 also had a valid (nonlocal) IP address listed later in the file. 127.0.0.1 isn't very useful in my application because it's sent to another host, not used locally. _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message