public static void scan(InetAddress remote) {
String hostname = remote.getHostName();
for (int port = 0; port < 65536; port++) {
try {
Socket s = new Socket(remote, port);
System.out.println("A server is listening on port "
+ port + " of " + hostname);
s.close();
}
catch (IOException e) {
// The remote host is not listening on this port
}
}
}
Previous slide | Next slide | Back to first slide | View graphic version |