March 2002
Intermediate to advanced
864 pages
31h 8m
English
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);
}
}