Note that there are some explanatory texts on larger screens.

plurals
  1. POSafe Java Pinging
    primarykey
    data
    text
    <p>I have a project that pings all computera on LAN network. First I used <code>InetAddress.isReachable()</code> but sometimes function returns that IP is not reachable() even if IP is reachable(tried with build in function on windows and IP was reachable) . Second i tried with this code:</p> <pre><code>Process proc = new ProcessBuilder("ping", host).start(); int exitValue = proc.waitFor(); System.out.println("Exit Value:" + exitValue); </code></pre> <p>But output is wrong. Then I googled a bit and find out this code:</p> <pre><code>import java.io.*; import java.util.*; public class JavaPingExampleProgram { public static void main(String args[]) throws IOException { // create the ping command as a list of strings JavaPingExampleProgram ping = new JavaPingExampleProgram(); List&lt;String&gt; commands = new ArrayList&lt;String&gt;(); commands.add("ping"); commands.add("-n"); commands.add("1"); commands.add("192.168.1.1"); ping.doCommand(commands); } public void doCommand(List&lt;String&gt; command) throws IOException { String s = null; ProcessBuilder pb = new ProcessBuilder(command); Process process = pb.start(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream())); // read the output from the command System.out.println("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // read any errors from the attempted command System.out.println("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { System.out.println(s); } } } </code></pre> <p>This code worked fine but problem is when Windows is on other langauge you can't tell if address is reachable or not. Can you guys share with me a safe method how to ping IP addresses on LAN or VPN network. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload