When I open firefox and enter “209.191.122.70” as the URL and press enter, it immediately resolves to “http://failsafe.fp.yahoo.com/404.html”
My goal is to retrieve the same information programmatically.
When I use the following code, either I end up with a SocketException or I end up with a HostName that doesn’t look like the url I get when I use firefox.
static void Main(string[] args)
{
IPHostEntry entry = Dns.GetHostByAddress("209.191.122.70");
Console.WriteLine(entry.HostName); //ir1.fp.vip.mud.yahoo.com
Console.Read();
}
The System.Net.Sockets.SocketException I get when I try some other addresses says “The requested name is valid, but no data of the requested type was found” and the stack trace looks as follows:
at System.Net.Dns.InternalGetHostByAddress(IPAddress address, Boolean includeIPv6, Boolean throwOnFailure)
at System.Net.Dns.GetHostByAddress(String address)
at reverseIP.Program.Main(String[] args) in C:\test\Program.cs:line 15
Some of the addresses that give me exceptions resolve fine in firefox.
Other than starting Firefox as a separate process and retrieving the text in the address bar using the Windows API, how can I retrieve the information I’m looking for?
The System.Windows.Forms.WebBrowser class helped me obtain the info I was looking for.