FileDocCategorySizeDatePackage
lookForLocalPorts.javaAPI DocExample546Thu Apr 03 15:24:28 BST 1997None

lookForLocalPorts

public class lookForLocalPorts extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    
    ServerSocket theServer;

    for (int i = 1024; i <= 65535; i++) {
      try {
        // the next line will fail and drop into the catch block if
        // there is already a server running on port i
        theServer = new ServerSocket(i);
        theServer.close();
      }
      catch (IOException e) {
        System.out.println("There is a server on port " + i + ".");
      } // end try
    } // end for