Results 1 to 1 of 1

Thread: Helpp

  1. #1
    stiln is offline Member
    Join Date
    Dec 2015
    Posts
    3
    Rep Power
    0

    Post Helpp

    Hey All,
    I am working on a project in which i have to create a java application on having the information of devices in the same network.
    I just want to find the IP address and Computer names.

    Here i've found some code online and do some editing. but, does this appropriate to be used to check on all connected devices in the same network? or are there better way to do it?


    Thanks & Regard
    Stiln D


    Java Code:
    package pinger;
    
    import java.io.IOException;
    
    import java.net.InetAddress;
     
    public class NetworkPing {
     
    	
    	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");
    		//}
    		
    		
    		}
     //System.out.println("End of searching");
    	}
    }
    Last edited by stiln; 12-15-2015 at 09:17 AM. Reason: change main forum group

Similar Threads

  1. Help needed!!!!! choosing network computers
    By apoorv in forum Networking
    Replies: 6
    Last Post: 03-22-2011, 05:33 PM
  2. How do i get a list of SQL Servers from network?
    By flyto9 in forum Networking
    Replies: 0
    Last Post: 03-16-2011, 05:13 PM
  3. How to list all computer in a network?
    By CaptnCAPSLOCK in forum Networking
    Replies: 1
    Last Post: 01-24-2011, 01:12 PM
  4. Replies: 0
    Last Post: 04-07-2009, 10:35 PM
  5. Sockets for computers in wireless network
    By etrynus in forum Networking
    Replies: 2
    Last Post: 12-02-2008, 11:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •