Merge pull request #829 from symform/httpwebreq-async-ssl
[mono.git] / mcs / class / System / System.Net / Dns.cs
index d8d3f119ce26b82efb070641e9fe3723a92d5855..fb532cd22c2a8a19929b6cfe1b85a20f08d00f7d 100644 (file)
@@ -126,7 +126,7 @@ namespace System.Net {
                                throw ares.Exception;
                        IPHostEntry entry = ares.HostEntry;
                        if (entry == null || entry.AddressList == null || entry.AddressList.Length == 0)
-                               throw new SocketException(11001);
+                               Error_11001 (entry.HostName);
                        return entry;
                }
 #endif
@@ -293,7 +293,13 @@ namespace System.Net {
                private extern static bool GetHostName_internal(out string h_name);
 #endif 
 
-               private static IPHostEntry hostent_to_IPHostEntry(string h_name, string[] h_aliases, string[] h_addrlist) 
+               static void Error_11001 (string hostName)
+               {
+                       throw new SocketException(11001, string.Format ("Could not resolve host '{0}'", hostName));
+
+               }
+
+               private static IPHostEntry hostent_to_IPHostEntry(string originalHostName, string h_name, string[] h_aliases, string[] h_addrlist) 
                {
                        IPHostEntry he = new IPHostEntry();
                        ArrayList addrlist = new ArrayList();
@@ -317,7 +323,7 @@ namespace System.Net {
                        }
 
                        if(addrlist.Count == 0)
-                               throw new SocketException(11001);
+                               Error_11001 (originalHostName);
 
                        he.AddressList = addrlist.ToArray(typeof(IPAddress)) as IPAddress[];
                        return he;
@@ -377,9 +383,9 @@ namespace System.Net {
 #else
                        bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist);
                        if (!ret)
-                               throw new SocketException(11001);
+                               Error_11001 (address);
 #endif
-                       return (hostent_to_IPHostEntry (h_name, h_aliases, h_addrlist));
+                       return (hostent_to_IPHostEntry (address, h_name, h_aliases, h_addrlist));
                        
                }
 
@@ -456,9 +462,9 @@ namespace System.Net {
 
                        bool ret = GetHostByName_internal(hostName, out h_name, out h_aliases, out h_addrlist);
                        if (ret == false)
-                               throw new SocketException(11001);
+                               Error_11001 (hostName);
 
-                       return(hostent_to_IPHostEntry(h_name, h_aliases, h_addrlist));
+                       return(hostent_to_IPHostEntry(hostName, h_name, h_aliases, h_addrlist));
 #endif
                }
 
@@ -472,7 +478,7 @@ namespace System.Net {
                        bool ret = GetHostName_internal(out hostName);
 
                        if (ret == false)
-                               throw new SocketException(11001);
+                               Error_11001 (hostName);
 
                        return hostName;
 #endif