[Mono-list] Getting list of IPAddress available

Dick Porter dick@ximian.com
Tue, 30 Nov 2004 10:38:32 +0000

On Mon, 2004-11-29 at 12:14 -0800, Jim P. wrote:
> I'm working with System.Net.Sockets.  I'm trying to get a listing of the
> available IPAddress on the machine.  When I run this on my Windows XP box
> I get the IP of my NIC:  But when I run this on my Fedora
> Core 2 Server I only get  I have 1 NIC on this box that works
> fine and is on IP
> Any idea why the NIC on THE PC would show up fine but not on the Fedora
> box?
> Here is the code I'm using to check for the IPs:

>  // get the IP address list..
>  IPHostEntry ipEntry = Dns.GetHostByName (Dns.GetHostName());
>  IPAddress [] addr = ipEntry.AddressList;

You're doing a DNS lookup.  If there are multiple addresses in the DNS
tables then mono will find them.

It seems that the windows resolver will also return the addresses of all
local interfaces if you try and look up the hostname.  See bug

- Dick