문제

I have few servers, and would like to decide in my java client what is the nearest machine (with shortest time for tcp connection).
Is there any library who does that in java?
If not, what is the best way to do that? I prefer to do that without actually connecting to the my server application if that is possible.

도움이 되었습니까?

해결책

A simple way would be:

InetAddress.getByName(host).isReachable(timeOut)

Or with an Http client if you are willing to reach for an application rather than a host.

And measure time before and after, then sort the hosts.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top