LocalScan.java Source code

Java tutorial

Introduction

Here is the source code for LocalScan.java

Source

import java.net.ServerSocket;

public class LocalScan {
    public static void main(String[] args) {
        for (int i = 1; i < 1023; i++) {
            testPort(i);
        }
        System.out.println("Completed");
    }

    private static void testPort(int i) {
        try {
            ServerSocket sock = new ServerSocket(i);
        } catch (java.io.IOException e) {
            System.out.println("Port " + i + " in use.");
        }
    }
}