Results 1 to 1 of 1
Thread: Java version of ping
- 06-29-2012, 09:37 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Java version of ping
I need to ping a remote site to see if it is available for service.
When I ping it from a command shell (e.g., "ping www.yahoo.com"), it shows the site is accessible.
So I run the following Java.
After the system times out, it outputs reachable as false.Java Code:import java.net.InetAddress; public class Test { static String yahoo = "www.yahoo.com"; public static void main(String[] args) throws Exception { InetAddress address = InetAddress.getByName(yahoo); boolean reachable = address.isReachable(10000); System.out.println("Is host reachable? " + reachable); } }
If I point getByName at my router, it works fine. Clearly ping is able to look beyond the LAN, but the Java code cannot.
My question is why not? Does it have to do with the router letting certain sockets through (e.g., the one associated with ping) but not others (e.g., the one used by InetAddress)?
Similar Threads
-
Ping in Java
By VeasMKII in forum New To JavaReplies: 7Last Post: 10-14-2012, 09:51 PM -
Ping an IP address in java application
By ramanareddy438 in forum Advanced JavaReplies: 1Last Post: 12-06-2011, 09:49 AM -
java -version pointing to older version
By deepakts in forum New To JavaReplies: 4Last Post: 05-06-2010, 09:59 AM -
How to mesure ping delay in JAVA..?
By sacr83 in forum NetworkingReplies: 4Last Post: 06-15-2008, 06:37 AM -
How to write a JAVA program to mesure ping delay..?
By sacr83 in forum NetworkingReplies: 1Last Post: 02-15-2008, 04:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks