Local Port Scanner : Port « Network « Java Tutorial






import java.io.IOException;
import java.net.ServerSocket;

public class MainClass {

  public static void main(String[] args) {

    for (int port = 1; port <= 65535; port++) {

      try {
        // the next line will fail and drop into the catch block if
        // there is already a server running on the port
        ServerSocket server = new ServerSocket(port);
      } catch (IOException ex) {
        System.out.println("There is a server on port " + port + ".");
      }
    }
  }
}








19.10.Port
19.10.1.Low Port Scanner
19.10.2.High Port Scanner
19.10.3.Port Scanner
19.10.4.Local Port Scanner
19.10.5.UDP Port Scanner