Asp.net IP反查域名/主机名

public string GetHostNameByIp( string ip)
{
     ip = ip.Trim();
     if (ip == string .Empty)
         return string .Empty;
     try
     {
         // 是否 Ping 的通
         if ( this .Ping(ip))
         {
             System.Net.IPHostEntry host =
             System.Net.Dns.GetHostEntry(ip);
             return host.HostName;
         }
         else
             return string .Empty;
     }
     catch (Exception)
     {
         return string .Empty;
     }
}

转载优特建站:http://www.youtiy.com/Articles/Item.aspx?Id=256

你可能感兴趣的:(return,public,主机)