PortScanner


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ce5a2012project01;

 import java.net.Socket;/**
 *
 * @author Sita
 */
public class JavaPortScanner {
     /**
     * @param args
     */
    public void JavaPortScannerUtil() {

        for (int i = 79; i < 81; i++) {
            Portscanner(i);
        }
        System.out.println("Port Scan completed!!");
    }
    private void Portscanner(int i) {
        // TODO Auto-generated method stub
        try {
            Socket socket = new Socket("localhost",i);
            System.out.println("Port " + i + " is in use.");
        } catch (java.io.IOException e) {
            System.out.println("Port " + i + " is not use.");
        }
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        JavaPortScanner jpsc = new JavaPortScanner();
        jpsc.JavaPortScannerUtil();
    }
}

Komentar