public static int findAAvailablePort(int start,int end){
  int finalPort=-1;
  for (int i=0; i < 20; ++i) {
    int port=start + (int)(Math.random() * (end - start));
    if (available(port)) {
      finalPort=port;
      break;
    }
  }
  return finalPort;
}

public static int findAAvailablePort ( int start , int end ) { int finalPort = - 1 ; for ( int i = 0 ; i < 20 ; ++ i ) { int port = start + ( int ) ( Math . random ( ) * ( end - start ) ) ; if ( available ( port ) ) { finalPort = port ; break ; } } return finalPort ; }
a random avaiable port between start and end
