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 8197605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:46:35+00:00 2026-06-07T05:46:35+00:00

I have trimmed my code down to the bare essentials, its pretty simple and

  • 0

I have trimmed my code down to the bare essentials, its pretty simple and straight forward.

I have the following code:

public ArrayList<Node> getNodes() throws IOException
{
    ArrayList<Node> nodes = new ArrayList<Node>();

    StringBuffer root = new StringBuffer(InetAddress.getLocalHost().getHostAddress());
    while(!root.toString().endsWith("."))
        root.deleteCharAt(root.length() - 1);
    //^^ this code gets the ip, for ex 127.0.0.1, and trims the last number, to make it
    //^^ 127.0.0.  <-- see the trailing 0

    for(int host = 0;host < 256; host++)
    {
        InetAddress address = InetAddress.getByName(root.toString() + host);
        try
        {
            if(address.isReachable(500)) // pings the address
                nodes.add(new Node(address.getHostAddress(), false));
        }catch(Exception e){new Node(address.getHostAddress(), true);}
    }

    return nodes;
}

Here is the node class, which is pretty simple:

public class Node 
{
    public Node(String address, boolean restricted)
    {
        this.address = address;
        this.restricted = restricted;
    }

    public String address;
    public boolean restricted;
}

Here is my main code, which executes getNodes():

case 1:
    System.out.println("Searching for nodes...");
    NodeDetector node = new NodeDetector(); // this is the class
                                           //where getNodes resides
    ArrayList<Node> nodes = node.getNodes();

    Iterator<Node> it = nodes.iterator();
    while(it.hasNext())
    {
        System.out.println("Node: "+it.next().address);
    }

    System.out.println("stopped searching for nodes...");
    break;

Here is my output:

Searching for nodes...
Node: 00.00.17.99
Node: 00.00.17.100
Node: 00.00.17.149
Node: 00.00.17.150 <-- this is my computer
Node: 00.00.17.154
Node: 00.00.17.156
Node: 00.00.17.254
stopped searching for nodes...

Now here’s the problem

I have a network node discovery tool i downloaded on my phone and it can find at least 5 more nodes. I tried changing the timeout value but still no luck. When i ping an address that is found with the network tool on my phone and not on my computer, the ping is instantly received and returned. This question is similar and it has helped me a bit, but I’m still stuck:

  • How to do a true Java ping from Windows?

I am running my tool on a mac, it seems to work well picking up other macs, iPods and routers but thats about it. Why can’t my program detect the other devices on the network?


Here is the output i get from my network tool on my phone:

00.00.17.99 <-- SMC Networks *
00.00.17.100 <-- XEROX *
00.00.17.133 <-- My Phone (Android)
00.00.17.134 <-- Intel
00.00.17.142 <-- Apple
00.00.17.149 <-- Apple *
00.00.17.150 <-- Apple * <-- this is my computer
00.00.17.154 <-- Apple *
00.00.17.155 <-- Intel
00.00.17.156 <-- Apple *
00.00.17.158 <-- Motorola Mobility
00.00.17.254 <-- Netopia *

I put an * where the tool on my phone agrees with the tool i am writing on my computer. I have ran this test a couple of times, i get the same output every time on both my computer and on my phone, no devices were added or removed from the network during the tests.

  • 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-07T05:46:35+00:00Added an answer on June 7, 2026 at 5:46 am

    After a couple days of research I have come across this as an ok solution:

    try
    {
        Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 -W 250 " + address.getHostAddress());
        int returnVal = p1.waitFor();
        boolean reachable = (returnVal==0);
    
    
        if(reachable)
            nodes.add(new Node(address.getHostAddress(), false));
    }catch(Exception e)
    {
        new Node(address.getHostAddress(), true);
    }
    

    The only drawback on this is that it is system dependent. Im going to be the only one using this tool so that really is no problem for me.

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

Sidebar

Related Questions

I have the following (trimmed) markup: <asp:Repeater ID=CostCategoryRepeater runat=server> <ItemTemplate> <div class=costCategory> <asp:Repeater ID=CostRepeater
I have a very trimmed down example that creates a segfault that I can't
I have an embedded processor that is running a trimmed down version of BASIC
This is heavily trimmed down source code from a webpage I'm working on right
EDIT : the code has been trimmed down to contain only what is necessary
I have a sample code snippet below which works just fine (I trimmed the
I have the following code for use in my asp.net website: CalendarService service =
I have the following piece of code. I've recorded the output as well: function
I have a theory why the following code is not producing the results I
Have you ever obfuscated your code before? Are there ever legitimate reasons to do

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.