I was surprised to learn that a single domain name can have many IP addresses. For example, here are my results for Dns.GetHostAddresses("www.google.com")
:
{System.Net.IPAddress[6]}
[0]: {74.125.127.147}
[1]: {74.125.127.99}
[2]: {74.125.127.103}
[3]: {74.125.127.104}
[4]: {74.125.127.105}
[5]: {74.125.127.106}
(YMMV; the addresses seem to change periodically)
Where do these different addresses come from, and how should one choose an IP address to connect to?
The IP addresses come from the DNS server associated with the queried domain name, www.google.com in your example. This would be the same process a web browser follows to get the server IP addresses to connect to.
As for which IP address to connect to I'd imagine they're all redundant and you should probably just connect to the first one, however this is just speculation and I don't really know for sure.