public static IPHostEntry GetIPHostEntry(string host)
{
IPHostEntry ipEntry;
#if CACHE_HOSTENTRIES
string hostUpperName = host.ToUpper();
lock (_syncLock)
{
if (!CachedIPHostEntries.TryGetValue(hostUpperName, out ipEntry))
{
try
{
ipEntry = Dns.GetHostEntry(hostUpperName);
CachedIPHostEntries.Add(hostUpperName, ipEntry);
}
catch
{
ipEntry = null;
}
}
}
#else
try
{
ipEntry = Dns.GetHostEntry(host);
}
catch
{
ipEntry = null;
}
#endif
return ipEntry;
}