I've been trying to find the correct situtation when to use GetHostAddresses or GetHostEntry. I understand by reading this article (http://msdn.microsoft.com/en-us/library/ms143998(v=vs.110).aspx) that GetHostEntry will do the reverse dns lookup and GetHostAddresses does not..
However under what exact scenario you need to use GetHostEntry rather than GetHostAddresses? also, what is the primary reason for GetHostEntry method to perform reverse DNS lookup?
The GetHostEntry method queries a DNS server for the IP address that is associated with a host name or IP address.The method assumes that if an IP literal string is passed in the hostNameOrAddress parameter that the application wants an IPHostEntry instance returned with all of the properties set. These properties include the AddressList, Aliases, and HostName. This method can be used if you want to find the hostname associated with an IP address.
Reverse DNS is mostly for such things as tracking where a web-site visitor came from, or where an e-mail message originated etc. It is typically not as critical in as forward DNS - visitors will still reach your web-site just fine without any reverse DNS for your web-server IP or the visitor's IP. Reverse DNS is important for one particular application.Many e-mail servers on the Internet are configured to reject incoming e-mails from any IP address which does not have reverse DNS.
But the GetHostAddresses method queries a DNS server for the IP addresses associated with a host name. If hostNameOrAddress is an IP address, this address is returned without querying the DNS server. This query will return all the IP addresses related to the hostname you provide.
The difference between GetHostEntry and GetHostAddresses is that whenever you give an IP address to GetHostEntry it will query the DNS server and try to get the hostname for that IP address and then get all the addresses associated with it.If the data for a successfull reverse resolve is not in your DNS server, this will fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With