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
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();
}
if(addrlist.Count == 0)
- throw new SocketException(11001);
+ Error_11001 (originalHostName);
he.AddressList = addrlist.ToArray(typeof(IPAddress)) as IPAddress[];
return he;
#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));
}
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
}
bool ret = GetHostName_internal(out hostName);
if (ret == false)
- throw new SocketException(11001);
+ Error_11001 (hostName);
return hostName;
#endif