I have few servers, and I would like to decide in my java client what is the closest machine (with the shortest time to connect tcp).Is there a library that does this in java?If not, what is the best way to do this? I prefer to do this without actually connecting to my server application, if possible.
A simple way would be:
InetAddress.getByName(host).isReachable(timeOut)
Or using Http clientif you want to contact the application, not the host.
Http client
And measure the time before and after, then sort the hosts.