docs: private ReturnCode write(String command, ReturnCode notStartedRC, ReturnCode errorRC) {
          SocketChannel channel = null;
          try {
              ServerCommandID commandID = createServerCommand(command);
              if (commandID.getPort() > 0) {
                  channel = SelectorProvider.provider().openSocketChannel();
                  channel.connect(new InetSocketAddress(InetAddress.getByName(null), commandID.getPort()));
  
                  // Write command.
                  write(channel, commandID.getCommandString());
  
                  // Receive authorization challenge.
                  String authID = read(channel);
  
                  // Respond to authorization challenge.
                  File authFile = new File(commandAuthDir, authID);
                  // Delete a file created by the server (check for write access)
                  authFile.delete();
  
                  // respond to the server to indicate the delete has happened.
                  write(channel, authID);
  
                  // Read command response.
                  String cmdResponse = read(channel), targetServerUUID = null, responseCode = null;
                  if (cmdResponse.isEmpty()) {
                      throw new IOException("connection closed by server without a reply");
                  }
  
                  if (cmdResponse.indexOf(DELIM) != -1) {
                      targetServerUUID = cmdResponse.substring(0, cmdResponse.indexOf(DELIM));
                      responseCode = cmdResponse.substring(cmdResponse.indexOf(DELIM) + 1);
                  } else {
                      targetServerUUID = cmdResponse;
                  }
                  if (!commandID.validateTarget(targetServerUUID)) {
                      throw new IOException("command file mismatch");
                  }
                  ReturnCode result = ReturnCode.OK;
                  if (responseCode != null) {
                      try {
                          int returnCode = Integer.parseInt(responseCode.trim());
                          result = ReturnCode.getEnum(returnCode);
                      } catch (NumberFormatException nfe) {
                          throw new IOException("invalid return code");
                      }
                  }
                  if (result == ReturnCode.INVALID) {
                      throw new IOException("invalid return code");
                  }
                  return result;
              }
  
              if (commandID.getPort() == -1) {
                  return ReturnCode.SERVER_COMMAND_PORT_DISABLED_STATUS;
              }
  
              return notStartedRC;
          } catch (ConnectException e) {
              Debug.printStackTrace(e);
              return notStartedRC;
          } catch (IOException e) {
              Debug.printStackTrace(e);
              return errorRC;
          } finally {
              Utils.tryToClose(channel);
          }
      }