Scan your computer for ports in use

The following code snippet will help you to scan using ports in your computer.


Freelance Jobs


LocalScan class



import java.net.ServerSocket;


public class LocalScan{
public static void main(String[] args){
for (int i = 1; i < 10230; i++) {
testPort(i);
}
System.out.println("Completed");
}
private static void testPort(int i) {
try {
ServerSocket sock = new ServerSocket(i);
System.out.println("Port " + i + " not in use.");
}catch (java.io.IOException e) {
//System.out.println("Port " + i + " in use.");
}
}
}

Comments

Popular Posts