import java.net.*;
import java.io.IOException;
import javax.swing.*;
public class Trial
{
public static void main(String args[])
{
try
{
String str=JOptionPane.showInputDialog("Enter the host name");
InetAddress ia=InetAddress.getByName(str);
System.out.println("ip address is"+ia);
for(int i=80;i<130;i++)
{
try
{
Socket s=new Socket(ia,i);
System.out.println("port "+i+" is open");
s.close();
}
catch(IOException e)
{
System.out.println("port "+i+"is off");
}
}
}
catch(UnknownHostException e)
{ }
}
}
Written by Naresh in
Port scanning
Popular Posts
-
import java.io.*; import java.net.*; import java.util.Scanner; /** Fetches the HTML content of a web page (or HTTP header) as a String....
-
import java.util.*; import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class common extends Panel im...
-
Calculator.java public interface Calculator extends java.rmi.Remote { public long add(long a,long b) throws java.rmi.RemoteException; ...
-
Client import java.io.*; import java.net.*; class client { public static void main(String args[])throws Exception { String str;...
-
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Bully { static int n,pc,in...
-
import java.net.*; import java.io.IOException; import javax.swing.*; public class Trial { public static void main(String args[]) { ...
-
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Ring { static int n,pc,i...