August 2003
Intermediate to advanced
928 pages
32h 1m
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);
}
}