Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

LAN ping app. - Java Code Bank


LAN ping app.
Pings IP addresses in a 192.168.x.x block. Might add multithreading later since it's quite slow.
                import java.io.*;
import java.net.*;
import java.net.InetAddress;

public class pingBlock
{
	public static void main(String args[])
	{
		int oct1, oct2;
		
		for(oct1 = 1; oct1 <=255; oct1++)
		{
			for(oct2 = 1; oct2 <=255; oct2++)
			try
		{
			InetAddress address = InetAddress.getByName(String.format("192.168.%d.%d", oct1, oct2));
			boolean reachable = address.isReachable(500);

			System.out.println("Addr: " + address.getHostAddress());
       		System.out.println("Reach: " + address.isReachable(500));
    	}
    		catch (UnknownHostException e)
    		{
    			System.out.println("unable to look up IP Address block");
    		}
			catch (IOException e)
			{
				System.out.println("unable to look up IP Address block");
			}
		}
	
	}
}

            
Comments
Sorry but there are no comments to display