Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java get all ip addresses in a lan
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


kallanpv
java get all ip addresses in a lan
5 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners


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.


Advertisement
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
Get GMT from IP
Get GMT from IP  How do I get GMT value from IP address?? Thanx in Adv
Java Get IP Address
Java Get IP Address       This section illustrates you how to obtain the IP Address of local host... getHostAddress() returns the IP address.     Here is the code of Java Get IP
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: <?php echo "My Browser IP is :". $_SERVER['REMOTE_ADDR']; ?>
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 GD Get System IP
<?php $image = imagecreatetruecolor(150,70); $ip = "$_SERVER[REMOTE_ADDR]"; imagestring($image, 10, 20, 36, $ip, 0x00ff00); header... running the program you will get the following output
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 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
Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java... how to get all keys and it's values of the properties files in Java. Java... to be inserting in the properties files. Here, you will get the all keys and values
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...: Here, you will get all keys and values of the properties files with the help
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
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
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
Java Get Example
practice   IP Address:  This Java Get IP Address example... in the network for communication. To get IP address of our own system in a java.... Java get available Font In order to retrieve all the available fonts, we have used
Java Get Example
practice   IP Address:  This Java Get IP Address... in the network for communication. To get IP address of our own system in a java... Java Get Example      
LAN - JSP-Servlet
LAN  hi i want java code for LAN messenger.plse sens me
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
Example program to get all the available time zones
to get all the available time zones using java program. This example is very simple java code that will list all the available time zones. We have used... Example program to get all the available time zones
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 Host Name
Java Get Host Name       In this Example you will learn how to get host name in Java. Go through... of a computer or an IP address using Java application language. The given program
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
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
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
IP converson
IP converson  How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com
 

 

 

DMCA.com