DNS Lookup Using .NET


Another in the occasional series about using Microsoft .NET, this time to translate between IP addresses and host names

     ∇z←DnsLookup w;⎕IO;⎕ML;⎕USING;dns;⎕TRAP
⍝ Experimental DNS lookup
 ⎕IO ⎕ML←0 3
 ⎕USING←'System,System.dll' 'System.Net'
 :Trap 90
     dns←Dns.GetHostEntry⊂w
     z←dns.(HostName AddressList)
 :Else
     z←⍬ ⍬
 :EndTrap


Sample usage:

    DnsLookup 'dyalog.com'
 dyalog.com   62.121.2.168 
    DnsLookup '62.121.2.168'
 linweb.dyalog.com   62.121.2.168  2001:470:1f08:7bf::2 


Notes:
Page created 28 January 2009.
Copyright © Dogon Research 2009.