java get all ip addresses in a lan

java get all ip addresses in a lan

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.

View Answers

April 12, 2011 at 8:32 PM

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
}

}


May 20, 2011 at 4:31 PM

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


October 28, 2011 at 2:26 AM

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.


October 28, 2011 at 3:04 AM

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();
        }

    }

}

October 28, 2011 at 3:05 AM

u may check it i m not conformed but it may work









Related Tutorials/Questions & Answers:
java get all ip addresses in a lan
java get all ip addresses in a lan  Anybody have any idea on using java or cpp on how to get the ip addresses of all the machines[win or linux... to know that a given ip address computer is connected in a LAN?. I could supply
how to get an lan system ip and mac address in java code
how to get an lan system ip and mac address in java code  strong text
Advertisements
block IP of LAN machines from server - RMI
block IP of LAN machines from server  i want to block the IP of machines from server ,that are connected in LAN.. all machines access net through... is it possible to block IP of LAN machines from server
Getting IP address of All the machines
Getting IP address of All the machines  Program how to fetch All the IP address on my domain(LAN) in java
Get IP Address in Java
Get IP Address in Java In this example we will describe How to get ip address in java. An IP address is a numeric unique recognition number which...(). getHostAddress(). InetAddress():-The InetAddress is class represents an IP address. ADS
Java Get IP Address
Java Get IP Address   ... tutorial of "How to get IP Address in Java?": Here is the code of Java Get IP Address ExampleADS_TO_REPLACE_2
Get GMT from IP
Get GMT from IP  How do I get GMT value from IP address?? Thanx in Adv
ModuleNotFoundError: No module named 'Get_ip'
ModuleNotFoundError: No module named 'Get_ip'  Hi, My Python..._ip' How to remove the ModuleNotFoundError: No module named 'Get_ip'... to install padas library. You can install Get_ip python with following command
VoIP LAN
wireless VoIP unit . All you need to do is connect the ethernet cable to your LAN...;   VoIP LAN Phone IN-Call LAN Phone is a full-featured IP... communication. Over the office LAN, it provides IP-PBX solution such as station
Get System Ip
Get System Ip      ... to get a IP address. For this we have a class name GetSystemIP,Inside the main... Interface made up of a name and a list of IP addresses assigned to this interface
PHP Get Browser IP Address
PHP Get Browser IP Address PHP provides us  $_SERVER['REMOTE_ADDR'] function is used to display the Browser IP address PHP Get IP Address Code:ADS_TO_REPLACE_1 <?php echo "My Browser IP is :". $_SERVER['REMOTE
Get IP Example
() : Network Interface class is used for get name, and a list of IP addresses... Get IP Example       This example shows you ip address of your network
Get IP Address Example
Get IP Address Example   ... : NetworkInterface.getNetworkInterfaces() : Network Interface class is used for get name, and a list of IP... for get the list of all InterfaceAddresses of this network interface
ModuleNotFoundError: No module named 'ip-info-all'
ModuleNotFoundError: No module named 'ip-info-all'  Hi, My Python... 'ip-info-all' How to remove the ModuleNotFoundError: No module named 'ip... you have to install padas library. You can install ip-info-all python
ModuleNotFoundError: No module named 'ip-info-all'
ModuleNotFoundError: No module named 'ip-info-all'  Hi, My Python... 'ip-info-all' How to remove the ModuleNotFoundError: No module named 'ip... you have to install padas library. You can install ip-info-all python
ModuleNotFoundError: No module named 'ip-info-all'
ModuleNotFoundError: No module named 'ip-info-all'  Hi, My Python... 'ip-info-all' How to remove the ModuleNotFoundError: No module named 'ip... you have to install padas library. You can install ip-info-all python
PHP GD Get System IP
<?php $image = imagecreatetruecolor(150,70); $ip = "$_SERVER[REMOTE_ADDR]";ADS_TO_REPLACE_1 imagestring($image, 10, 20, 36, $ip..._TO_REPLACE_2 ?> After running the program you will get the following output
Java example program to get IP address of own system
Java example program to get IP address of own system       java get own IP address An IP... is assigned to the devices participating in the network for communication. To get IP
problem in sending data from one ip to another ip in JAVA
device in JAVA. i know how to ping but don't how to send the msg's to another IP...problem in sending data from one ip to another ip in JAVA  Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip
LAN - JSP-Servlet
LAN  hi i want java code for LAN messenger.plse sens me
Find Exact Location from IP address in java?
Find Exact Location from IP address in java?  I am looking for API where we can pass IP address and get the location (Cityname,Country name). please suggest any API OR sample code. Thank you
Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java... to get all keys and it's values of the properties files in Java. Java provides... to be inserting in the properties files. Here, you will get the all keys and values
MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java
Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java... to get all keys and values of the properties files in the Java. This section...:ADS_TO_REPLACE_1 Here, you will get all keys and values of the properties files
Network monitoring under LAN
Network monitoring under LAN  am in search of a java program that monitors the real time traffic statistics such as datarate,traffic flow of a LAN....can any one help me by posting java codes or related ideas
ModuleNotFoundError: No module named 'lan'
ModuleNotFoundError: No module named 'lan'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'lan' How to remove the ModuleNotFoundError: No module named 'lan' error
ModuleNotFoundError: No module named 'lan'
ModuleNotFoundError: No module named 'lan'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'lan' How to remove the ModuleNotFoundError: No module named 'lan' error
ModuleNotFoundError: No module named 'lan'
ModuleNotFoundError: No module named 'lan'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'lan' How to remove the ModuleNotFoundError: No module named 'lan' error
ModuleNotFoundError: No module named 'lan'
ModuleNotFoundError: No module named 'lan'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'lan' How to remove the ModuleNotFoundError: No module named 'lan' error
Java Networking - JSP-Servlet
Java Networking  I want to get all systems' (computer,printer,laptop) IP address on LAN using java code. I tried a lot but find only my system's IP. I want java code for dat
Java Get Example
learning practice   IP Address:  This Java Get IP... provided. Java get available Font In order to retrieve all... Java Get Example      
Java Get Example
for better learning practice   IP Address:  This Java Get.... Java get available Font In order to retrieve all the available fonts, we have used... Java Get Example      
run project on company lan
run project on company lan  sir, i have create dynamic java project of complaint registration and run on local host http://localhost:8080 and by using ip adress but the problem is how to run it at on company server so
ModuleNotFoundError: No module named 'django-addresses'
ModuleNotFoundError: No module named 'django-addresses'  Hi, My... named 'django-addresses' How to remove the ModuleNotFoundError: No module named 'django-addresses' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-addresses'
ModuleNotFoundError: No module named 'django-addresses'  Hi, My... named 'django-addresses' How to remove the ModuleNotFoundError: No module named 'django-addresses' error? Thanks   Hi, In your
Website deployment on LAN
Website deployment on LAN  I have created a dynamic website in netbeans. Now i have to host the website on LAN so that by typing the URL of the project the users are able to view the content from their end. I have no idea
ModuleNotFoundError: No module named 'lan-presenter'
ModuleNotFoundError: No module named 'lan-presenter'  Hi, My... 'lan-presenter' How to remove the ModuleNotFoundError: No module named 'lan-presenter' error? Thanks   Hi, In your python
code for LAN Messenger - JSP-Servlet
code for LAN Messenger  User has to add the Valid System Name (the Name of the System on the LAN). After Adding System Name, he just have to Select... not have to Add the System Name again and again once user Close the Application all
Java Get Host Name
Java Get Host Name       In this Example you will learn how to get host name in Java... name of a computer or an IP address using Java application language. The given
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.5
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.5. You can add these depency in your project to get com.bol:ip-resource:1.4.5 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.4
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.4. You can add these depency in your project to get com.bol:ip-resource:1.4.4 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.2
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.2. You can add these depency in your project to get com.bol:ip-resource:1.4.2 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.1
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.1. You can add these depency in your project to get com.bol:ip-resource:1.4.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.3.1
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.3.1. You can add these depency in your project to get com.bol:ip-resource:1.3.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.2
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.2. You can add these depency in your project to get com.bol:ip-resource:1.2 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.1
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.1. You can add these depency in your project to get com.bol:ip-resource:1.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.0
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.0. You can add these depency in your project to get com.bol:ip-resource:1.0 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.0
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.4.0. You can add these depency in your project to get com.bol:ip-resource:1.4.0 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.3
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for ip-resource version 1.3. You can add these depency in your project to get com.bol:ip-resource:1.3 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape

Ads