java program
import java.net.*; import java.io.*; public class Main { public static void main(String[] args) { Socket Skt; String host = "localhost"; if (args.length gt;0) { host = args[0]; } for (int i = 0; i < 1024; i++) { try { System.out.println("Looking for "+ i); Skt = new Socket(host, i); System.out.println("There is a server on port "+ i + " of " + host); } catch (UnknownHostException e) { System.out.println("Exception occured"+ e); break; } catch (IOException e) { } } } }
Output
Looking for 0
Looking for 1
Looking for 2
Looking for 3
Looking for 4. . .
- Implementation of MD5 Algorithm in Java
- Implementation of RSA Algorithm(Encryption and Decryption) in Java
- java program to get the date of URL connection
- java program to read and download a webpage
- java program to find hostname from IP Address
- java program to determine IP Address & hostname of Local Computer?
- java program to check whether a port is being used or not
- java program to find proxy settings of a System
- java program to create a socket at a specific port
- java program to get the parts of an URL