code: public static boolean portAvailable(int port) {
          if (port < MIN_PORT || port > MAX_PORT) {
              throw new InvalidArgument("port is out of range");
          }
  
          ServerSocket ss = null;
          DatagramSocket ds = null;
          try {
              ss = new ServerSocket(port);
              ss.setReuseAddress(true);
              ds = new DatagramSocket(port);
              ds.setReuseAddress(true);
              return true;
          } catch (IOException e) {
              // Do nothing
          } finally {
              if (ds != null) {
                  ds.close();
              }
  
              if (ss != null) {
                  try {
                      ss.close();
                  } catch (IOException e) {
                      /* should not be thrown */
                  }
              }
          }
  
          return false;
      }
docs: Checks whether {@code port} is available.
  
  @param port the port to check, which must be between
  {@link BELUtilities#MIN_PORT} and {@link BELUtilities#MAX_PORT}
  @return {@code true} if the port is available for use, {@false}
  otherwise