9.7 Using DNS

The networking types in the base class library also support normal and reverse Domain Name System (DNS) resolution. Here's an example using these types:

 // DNSLookup.cs // Run DNSLookup.exe <servername> to determine IP addresses using System; using System.Net; class DNSLookup {   static void Main(string[ ] args) {     IPHostEntry he = Dns.GetHostByName(args[0]);     IPAddress[ ] addrs = he.AddressList;     foreach (IPAddress addr in addrs)       Console.WriteLine(addr);   } } 


C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net