code: public static boolean isPortAvailable(int p) {
          try {
              ServerSocket test = new ServerSocket(p);
              test.close();
          } catch (BindException e) {
              return false;
          } catch (IOException e) {
              return false;
          }
          return true;
      }
docs: used for windows multi-session emulation. Incremented at each new Rscript instance.