///& lt; Summary>
///incoming domain returns the corresponding IP
///& lt;/summary>
///& lt; Param name="domain" & gt; Domain name & lt;/param>
///& lt; Returns>
Public static string getIP (string domain)
{
Domain=domain. The Replace (" http://", ""). The Replace (" https://", "");
IPHostEntry hostEntry=Dns. GetHostEntry (domain);
IPEndPoint IPEndPoint=new IPEndPoint (hostEntry expressions such as AddressList [0], 0).
Return ipEndPoint. Address. The ToString ();
//IPAddress [] ips;
//ips=Dns. GetHostAddresses (domain);
//return ips [0]. ToString ();
}
Such as the DNS query will collapse at greenvpnn.com?
CodePudding user response:
Don't try this code, but according to the experience, if the network can't get to the Internet, abnormal there will be exceptions, such as DNS serviceAs if had twice this year, large-scale DNS service, the service if it is dependent on 8.8.8.8 and 114.114.114.114 error of the two DNS servers (ah, the original two is the fastest, most stable, the main for the double hung, later still need to do a variety of plans?)
CodePudding user response:
DNS will have a problem, but it is not common phenomenonTry this: IPAddress [] IPs=Dns. GetHostAddresses (" domain name ");
CodePudding user response: