Peter Sorotokin wrote:
Does it return a boolean value ? What does timeout mean in this code ?
Well, what does the javadoc for java.net.InetAddress say about what is returned from the isReachable() method?
As for the timeout, think of it like this... if the machine is reachable then it will respond saying that it is there. However, what happens if it is not reachable? Can it respond saying that it is not there? .. And what if it is reachable, but really slow because it has to go through routers? How many times and how long should you keep trying? ... anyway, that is what the timeout is for. In this example, the program will keep trying for four seconds, and assumes unreachable, if it doesn't get a response within that time.