[SOLVED] How to get List of All computers in my network or Computers Connected to me.

Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How to get List of All computers in my network or Computers Connected to me.

Hey All,
I am working on a project in which i have to install client software through server to all clients and the server could be a linux machine.
I just want to find the IP address and Computer names Connected to my system.

I will look into how we can get the details of machines connected to the server.

this info is very useful.
I would like to share some more details regarding my project.This is an client server architecture based project in this project we can install client software from server side, so i need to show all clients connected to the server.

Re: How to get List of All computers in my network or Computers Connected to me.

Hi ,

Try this code:

InetAddress localhost =InetAddress.getLocalHost();// this code assumes IPv4 is usedbyte[] ip = localhost.getAddress();for(int i =1; i <=254; i++){
ip[3]=(byte)i;InetAddress address =InetAddress.getByAddress(ip);if(address.isReachable(1000)){// machine is turned on and can be pinged}elseif(!address.getHostAddress().equals(address.getHostName()){// machine is known in a DNS lookup}else{// the host address and host name are equal, meaning the host name could not be resolved}}

Re: How to get List of All computers in my network or Computers Connected to me.

I have expanded on Amar's code slightly. It does the job but would be nice to speed it up..

importjava.io.IOException;importjava.net.InetAddress;publicclass NetworkPing {/**
* JavaProgrammingForums.com
*/publicstaticvoid main(String[] args)throwsIOException{InetAddress localhost =InetAddress.getLocalHost();// this code assumes IPv4 is usedbyte[] ip = localhost.getAddress();for(int i =1; i <=254; i++){
ip[3]=(byte)i;InetAddress address =InetAddress.getByAddress(ip);if(address.isReachable(1000)){System.out.println(address +" machine is turned on and can be pinged");}elseif(!address.getHostAddress().equals(address.getHostName())){System.out.println(address +" machine is known in a DNS lookup");}else{System.out.println(address +" the host address and host name are equal, meaning the host name could not be resolved");}}}}