C# IPHostEntry Cache???
-
Here is one of the coolest few lines of code to perform a NSLookUp. Simply enter an IP in textBox1, click a button and the domain name translates in textBox2 (providing your workstation is on a WAN. Q. How could we build a 'cache' to capture redundant IP's/Domain's to add lookup performance??? Q. How could we add our own know IP's/Domain's to this 'cache' ??? (Because NOT every IP will resolve) Preferably the code would check our personal 'cache' first before looking on the Internet or elsewhere..... public void ButtonLookupDomain_Click(object sender, EventArgs ea) { IPHostEntry IP = Dns.Resolve(textBox1.Text); txtBox2.Text = IP.HostName; }
-
Here is one of the coolest few lines of code to perform a NSLookUp. Simply enter an IP in textBox1, click a button and the domain name translates in textBox2 (providing your workstation is on a WAN. Q. How could we build a 'cache' to capture redundant IP's/Domain's to add lookup performance??? Q. How could we add our own know IP's/Domain's to this 'cache' ??? (Because NOT every IP will resolve) Preferably the code would check our personal 'cache' first before looking on the Internet or elsewhere..... public void ButtonLookupDomain_Click(object sender, EventArgs ea) { IPHostEntry IP = Dns.Resolve(textBox1.Text); txtBox2.Text = IP.HostName; }
if (somehashtable.Contains(textBox1.Text))
{
txtBox2.Text = (somehashtable[textBox1.Text] as IPHostEntry).HostName;
}
else
{
IPHostEntry IP = Dns.Resolve(textBox1.Text);
txtBox2.Text = IP.HostName;
somehashtable[textBox1.Text] = IP;
} -
if (somehashtable.Contains(textBox1.Text))
{
txtBox2.Text = (somehashtable[textBox1.Text] as IPHostEntry).HostName;
}
else
{
IPHostEntry IP = Dns.Resolve(textBox1.Text);
txtBox2.Text = IP.HostName;
somehashtable[textBox1.Text] = IP;
}Excellent, clean and simple coding. I like it so far... The more I study windows DNS, I realize my goal is to create my own 'hosts' file. I can write to it and IPHostEntry can read from it instead of the 'hashtable' you've so kindly shared. Q. How can I create my own 'hosts' file in place of the 'hashtable' example??? Thank You.....
-
Excellent, clean and simple coding. I like it so far... The more I study windows DNS, I realize my goal is to create my own 'hosts' file. I can write to it and IPHostEntry can read from it instead of the 'hashtable' you've so kindly shared. Q. How can I create my own 'hosts' file in place of the 'hashtable' example??? Thank You.....
kvnsdr wrote: The more I study windows DNS, I realize my goal is to create my own 'hosts' file. DNS was made to remove the need for HOSTS file. Heck you can even just edit the windows one then (i do for my little local network) in
$windir\system32\drivers\etc\hosts
top secret xacc-ide 0.0.1