From f8c569dc7c825d7ee8bf0fcbc225e3ec0f379862 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 05:18:37 +0000 Subject: * NetworkUtil now handles an error case in a way which is easier to debug. --- OpenSim/Framework/NetworkUtil.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/NetworkUtil.cs') diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 1abf0d8..759c52f 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Net.Sockets; using System.Net; using System.Net.NetworkInformation; @@ -65,8 +66,15 @@ namespace OpenSim.Framework return subnet.Key; } - // None found. Assume outside network. - return null; + // Check to see if we can find a IPv4 address. + foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) + { + if (host.AddressFamily == AddressFamily.InterNetwork) + return host; + } + + // Unable to find anything. + throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client"); } static NetworkUtil() -- cgit v1.1