public int forwardPort(int local, int remote) {
    CommandLine command = adbCommand("forward", "tcp:" + local, "tcp:" + remote);
    try {
      String portStr = ShellCommand.exec(command);
      return local == 0 ? Integer.parseInt(portStr) : local;
    } catch (ShellCommandException forwardException) {
      String debugForwardList;
      try {
        debugForwardList = ShellCommand.exec(adbCommand("forward", "--list"), 10000);
      } catch (ShellCommandException listException) {
        debugForwardList = "Could not get list of forwarded ports.";
      }

      throw new SelendroidException(
          "Could not forward port: " + command + "\nList of forwarded ports:\n" + debugForwardList,
          forwardException);
    }
  }
Constructor mean to be used with Android Hardware devices because a reference to the
{@link IDevice} will be available immediately after they are connected.

@param device
selendroid-standalone/src/main/java/io/selendroid/standalone/android/impl/AbstractDevice.java