Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:54:24+00:00 2026-06-08T06:54:24+00:00

So I have been using isReachable to ping an address in my java code.

  • 0

So I have been using isReachable to “ping” an address in my java code. This block of code is what everyone seems to use:

    try
    {
    InetAddress address = InetAddress.getByName("172.16.2.0");
    // Try to reach the specified address within the timeout
    // periode. If during this periode the address cannot be
    // reach then the method returns false.
    boolean reachable = address.isReachable(10000);
    System.out.println("Is host reachable? " + reachable);
    } catch (Exception e)
    {
    e.printStackTrace();
    }

My issue is that no matter what I use for my IP address it always returns true. Even if I change it to empty string. Any ideas why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:54:25+00:00Added an answer on June 8, 2026 at 6:54 am

    A way to check if some address is reachable, via java.net.InetAddress.isReachable() methods.
    The implementation of these methods goes native and tries to do its best to “ping” the address represented by the InetAddress.

    Surprisingly, there are many differences between the Windows and the Linux/Unix implementation of java.net.InetAddress.isReachable().

    Windows, as strange as it seems, does not officially support an ICMP “ping” system call. The Java SE 5 implementation hence tries to open a TCP socket on port 7 (the echo service) and hopes to get some sort of reply.

    Linux/Unix, instead, supports an ICMP “ping” system call. So the implementation of java.net.InetAddress.isReachable() first tries to perform the “ping” system call; if this fails, it falls back trying to open a TCP socket on port 7, as in Windows.

    It turns out that in Linux/Unix the ping system call requires root privileges, so most of the times java.net.InetAddress.isReachable() will fail, because many Java programs are not run as root.

    The correct approach is the ICMP protocol. This is what ping uses internally. It is recommended see THIS to gather knowledge and proceed.

    FROM: Simone Bordet’s Blog

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using an API to do some work. This is how I
I have been using these files all day... And then suddenly this is now
I have been using this script for a while and suddenly it just stopped
I have been using jQuery for a while. I wanted to use the parent()
I have been using LLVM and I was confused how to use a different
I have been using the examples from this site ( http://dojotoolkit.org/documentation/tutorials/1.6/datagrid/ ) to render
I have been using mySQL Quite a bit however, this is the first time
I have been using explode(.,$mystring) to split a paragraph into sentences. However this doen't
I have been using git to push my local code to a server. I
I have been using the following code for loading JQuery in all of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.