日期:2014-05-19  浏览次数:20877 次

请问各位,如何跟据域名得到当前服务器的IP?
如题,谢谢!

------解决方案--------------------
[C#]
public static IPHostEntry GetHostByName(
string hostName
);

------解决方案--------------------
Dns.GetHostByName(
string hostName
);

------解决方案--------------------
public static void DoGetHostAddresses(string hostname)
{
IPAddress[] ips;

ips = Dns.GetHostAddresses(hostname);

Console.WriteLine( "GetHostAddresses({0}) returns: ", hostname);

foreach (IPAddress ip in ips)
{
Console.WriteLine( " {0} ", ip);
}
}
------解决方案--------------------
using System.Net;