X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.Net%2FDns.cs;h=0ef74b1db930e8b4905e349eab4ca3b46fddacad;hb=6b41703ee1971df9c44309c7b252855d124ba399;hp=f4a2e47aea1d9ac8655ac8fe78d495e16936f9b1;hpb=c39d7ce9985a7067c1cbf44188007c9433901940;p=mono.git diff --git a/mcs/class/System/System.Net/Dns.cs b/mcs/class/System/System.Net/Dns.cs index f4a2e47aea1..0ef74b1db93 100644 --- a/mcs/class/System/System.Net/Dns.cs +++ b/mcs/class/System/System.Net/Dns.cs @@ -247,14 +247,20 @@ namespace System.Net { h_name = null; h_aliases = null; h_addrlist = null; - java.net.InetAddress[] iaArr = java.net.InetAddress.getAllByName (address); - if (iaArr != null && iaArr.Length > 0) - h_name = iaArr[0].getHostName (); - if (iaArr != null && iaArr.Length > 0) { - h_addrlist = new String[iaArr.Length]; - for (int i = 0; i < h_addrlist.Length; i++) - h_addrlist[i] = iaArr[i].getHostAddress (); - } + try { + java.net.InetAddress[] iaArr = + java.net.InetAddress.getAllByName(address); + if (iaArr != null && iaArr.Length > 0) + h_name = iaArr[0].getHostName(); + if (iaArr != null && iaArr.Length > 0) + { + h_addrlist = new String[iaArr.Length]; + for (int i = 0; i < h_addrlist.Length; i++) + h_addrlist[i] = iaArr[i].getHostAddress(); + } + } catch (java.net.UnknownHostException jUHE) { + throw new SocketException((int)SocketError.HostNotFound, jUHE.Message); + } #else bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist); if (!ret) @@ -318,21 +324,22 @@ namespace System.Net { #if TARGET_JVM if (hostName.Length == 0) hostName = "localhost"; - - java.net.InetAddress[] iaArr = java.net.InetAddress.getAllByName (hostName); - IPHostEntry host = new IPHostEntry (); - if (iaArr != null && iaArr.Length > 0) { - - host.HostName = iaArr[0].getHostName (); - - IPAddress[] ipArr = new IPAddress[iaArr.Length]; - for (int i = 0; i < iaArr.Length; i++) - ipArr[i] = IPAddress.Parse (iaArr[i].getHostAddress ()); - - host.AddressList = ipArr; - + try { + java.net.InetAddress[] iaArr = java.net.InetAddress.getAllByName(hostName); + IPHostEntry host = new IPHostEntry(); + if (iaArr != null && iaArr.Length > 0) + { + host.HostName = iaArr[0].getHostName(); + IPAddress[] ipArr = new IPAddress[iaArr.Length]; + for (int i = 0; i < iaArr.Length; i++) + ipArr[i] = IPAddress.Parse(iaArr[i].getHostAddress()); + + host.AddressList = ipArr; + } + return host; + } catch (java.net.UnknownHostException jUHE) { + throw new SocketException((int)SocketError.HostNotFound, jUHE.Message); } - return host; #else string h_name; string[] h_aliases, h_addrlist;