Skip to content

Commit e41dfd3

Browse files
Port Scanner.java
1 parent f4a04c7 commit e41dfd3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Port Scanner.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.net.*;
2+
3+
public class PortScanner {
4+
public static void main(String[] args) {
5+
String host = "localhost";
6+
7+
for (int port = 1; port <= 1000; port++) {
8+
try {
9+
Socket s = new Socket();
10+
s.connect(new InetSocketAddress(host, port), 50);
11+
System.out.println("Open: " + port);
12+
s.close();
13+
} catch (Exception e) {}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)