IsReachable in Java doesn't seem to work as intended

I use Clojure, but I can read Java, so this question is not Clojure. It doesn't even feel like working with Java.

I am trying to implement a bit of the "ping" function using isReachable. The code I use is as follows:

(.isReachable (java.net.InetAddress/getByName "www.microsoft.com") 5000)

Java translation by my good friend:

public class NetTest {
  public static void main (String[] args) throws Exception{
    String host = "acidrayne.net";
    InetAddress a = InetAddress.getByName(host);

    System.out.println(a.isReachable(10000));
  }
}

Both of them return false. I believe that I should do it wrong, but Google research tells me differently. I'm confused!

+5
source share
2 answers

Updated in response to a comment that this is wrong:

Using Unix / Linux

http://bordet.blogspot.com/2006/07/icmp-and-inetaddressisreachable.html says:

Linux/Unix, , ICMP "ping". , java.net.InetAddress.isReachable() "ping" **; , , TCP [sic - to] 7, Windows.

, Linux/Unix ping root, java.net.InetAddress.isReachable() , Java root , , , - . .

@EJP , - , :

. isReachable true, ConnectException, 7, , RST.

, WireShark, tcpdump (WinDump Windows) snoop (Solaris), , .

+3

, . Microsoft.com ICMP, , ping flood. , , ping, GNU/Linux isReachable .

+1

All Articles