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.
Re: How to get List of All computers in my network or Computers Connected to me.
Hello DanBrown,
Welcome to the Java Programming Forums.
Take a look at this link.
It will get the IP address and computer name of the local machine. I know its not what you need but its a place to start..
http://www.javaprogrammingforums.com...p-address.html
I will look into how we can get the details of machines connected to the server.
Re: How to get List of All computers in my network or Computers Connected to me.
Quote:
Originally Posted by
JavaPF
Hello DanBrown,
Welcome to the Java Programming Forums.
Take a look at this link.
It will get the IP address and computer name of the local machine. I know its not what you need but its a place to start..
http://www.javaprogrammingforums.com...p-address.html
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:
Code Java:
InetAddress localhost = InetAddress.getLocalHost();
// this code assumes IPv4 is used
byte[] 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
}
else if (!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..
Code Java:
import java.io.IOException;
import java.net.InetAddress;
public class NetworkPing {
/**
* JavaProgrammingForums.com
*/
public static void main(String[] args) throws IOException {
InetAddress localhost = InetAddress.getLocalHost();
// this code assumes IPv4 is used
byte[] 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");
}
else if (!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");
}
}
}
}
Re: How to get List of All computers in my network or Computers Connected to me.
I have done the same thing thank u all.