用C#获取地址!
using System;using System.Collections.Generic;
using System.Text;
using
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
ResolveDns resolver1 = new ResolveDns();
resolver1.Resolve("www.);
int n = resolver1.IPLength;
Console.WriteLine("Get the IP Address of the host");
Console.WriteLine();
for (int i = 0; i < n; i++)
Console.WriteLine(resolver1[i]);
Console.ReadKey();
}
class ResolveDns
{
IPAddress[] m_ArrayIps;
public void Resolve(string s_host)
{
IPHostEntry ip = Dns.GetHostByName(s_host);
m_ArrayIps = ip.AddressList;
}
public IPAddress this[int nIndex]
{
get { return m_ArrayIps[nIndex]; }
}
public int IPLength
{
get { return m_ArrayIps.Length; }
}
}
}
}