title: How to automatically connect to a server having multiple DNS entries, if 1 is down and only 1 IP address is working?
body: <p>A particular website has 2 DNS entries, i.e. 2 IP addresses for same hostname. But, one of the IP address is not working, only 1 works.</p>
  
  <p>I am trying to develop an HTTP Client without using HTTP libraries in Java. I am using Socket.connect(hostname, port) to connect to from my client to the server.</p>
  
  <p>I am using InetSocketAddress to resolve the hostname. If it resolves to working IP Address my HTTP Client works fine. If the non working IP address is resolved, I get a Unknown Host Exception.</p>
  
  <p>I am trying to handle this efficiently, i.e. when the non working IP address is selected, it should try to connect to another IP addresses. I am unable to achieve this. Appreciate all your help, thanks in advance.</p>