Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# IPHostEntry Cache???

C# IPHostEntry Cache???

Scheduled Pinned Locked Moved C#
csharpperformancequestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gman44
    wrote on last edited by
    #1

    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; }

    L 1 Reply Last reply
    0
    • G gman44

      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; }

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      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;
      }

      top secret xacc-ide 0.0.1

      G 1 Reply Last reply
      0
      • L leppie

        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;
        }

        top secret xacc-ide 0.0.1

        G Offline
        G Offline
        gman44
        wrote on last edited by
        #3

        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.....

        L 1 Reply Last reply
        0
        • G gman44

          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.....

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups