internal static void ClearCache() { fCache.Clear(); fLMHosts = null; }
private static IPAddress ResolveInLmHosts(string netbios) { if(fLMHosts == null) { string url = null; try { if(Debug.DebugOn && Debug.DebugLevel >= Debug.Info) Debug.WriteLine(Debug.Info, "Check name in LMHOSTS"); // Make this user-configurable later... url = Environment.SystemDirectory + @"\drivers\etc\lmhosts"; fLMHosts = new LmHosts(url); } catch(IOException) { Debug.WriteLine(Debug.Warning, "LMHOSTS file cannot be read: " + url); return null; } } string ip = fLMHosts.Lookup(netbios); if(ip != null) { try { return Dns.GetHostByName(ip).AddressList[0]; //return DNS.InetAddr(ip); // This converts the string into an instance of IPAddress } catch(Exception) { } } return null; }