Hi, I have a requirement to find a machine nearest to a server machine. The scenario is that I have a process running on different machines in a network. Now my server has to chose one of the process which is nearest to itself. Is is possible to find a machine which is closest using a Java API? Thanks Kapil
You could exec the "ping" utility with the IP addresses of the candidate machines, capture the text output and look for the shortest time. Here is what I got when pinging a local machine on my network.
Thanks for your replies. My application is a kind of asset management service running on a WAN. If a client check-in a file at a location say A, I would like to do some post check-in operations on that file by a process which is running closest to location A. I have no idea about JINI. Does Jini provide some api to get nearest host machine? Will it work over WAN? Thanks, Kapil
Author and all-around good cowpoke
Joined: Mar 22, 2000
u can also do it via using HttpUrlconnection
Wrong! HttpURLConnection is for connecting to HTTP servers via a precise URL, it has nothing to do with the requirement.
Joined: Dec 17, 2001
I checked up Jini and could not find any API which finds the nearest machine. There is a concept of location in Jini but that is just a meta data information of a service and has nothing to do with physical distance between two machines in a network. Regards,