dcsimg

Is there a way to programmatically find out if a port number is in use?

yathusree thirumalai

You can do the following:

try {
    ServerSocket s = new ServerSocket(portno);
}
catch(IOException e) {
    System.out.println("port " + portno + " already in use");
}