
Anybody have any idea on using java or cpp on how to get the ip addresses of all the machines[win or linux] connected to a computer in a LAN?. If this is not possible is there any function to know that a given ip address computer is connected in a LAN?. I could supply ip's and know the machine exists or not.

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
}
}

It takes too much time to find Ip addresses connected to LAN I have 100 PCS in Lan it takes 9 minutes so its is time consuming and i want display it in the Jcombobox so please give me the fastest way thanks and regards Nilesh Gawade

may be u can make it using Thread each Thread control over a limited range such as 10 0-9 and make array of Thread ........ use it.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
import java.io.*;
import java.awt.image.*;
import java.net.*;
public class NetScanner implements Runnable
{
String str;
int nub;
public NetScanner(String str,int nub)
{
this.str = str;
this.nub = nub;
}
/*
public void checkHost()
{
for(int i=0; i<256;i++)
{
if(IntelAddress.getByName(str+"."+i).isReachable(1000))
System.out.println("host"+str+"."+i+"is connected");
}
}
*/
public void run ()
{
try
{
for(int i=nub; i<nub+10;i++)
{
System.out.println(".......");
System.out.println(str);
System.out.println(nub);
if(InetAddress.getByName(str+"."+i).isReachable(1000))
System.out.println("host"+str+"."+i+"is connected");
}
}
catch(Exception e){System.out.println(e);}
}
public static void main(String []args)
{
//System.out.println("give subnet");
//Scanner out = new Scanner(System.in);
//NetScanner n = new NetScanner(out.next());
Thread t[] = new Thread[25];
for(int i=0; i<25;i++)
{
t[i] = new Thread(new NetScanner("10.124.168",i*10));
}
for(int i=0; i<25;i++)
{
t[i].start();
}
}
}

u may check it i m not conformed but it may work
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.