Here's a quick and fun code that you can try on. We know that the port no spans from 0 - 65535. So lets loop through that range and find the active ports in the system. This is called a Port Scanner . There are no steps to do this. Just make a loop and try to establish a connection . Implementation 01 import java.net.Socket ; public class MyPortScanner { public static void main ( String [] args ) { for ( int i = 0 ; i < 65535 ; i ++) { try { Socket ClientSoc = new Socket ( "localhost" , i ); System . out . println ( "Port " + i + " is active" ); ClientSoc . close (); } catch ( Exception e ) { System . out . println ( "Nope nothing on " + i + " port" ); } } } } The result I got was interesting. FYI this takes a longer time to finish scanning all 65535 ports. S...