private byte write(DataOutputStream dos, DataInputStream dis, CommunicationMode communicationMode,
      int replyCode, int readTimeout, List<String> ports, Properties p_credentials,
      DistributedMember member, boolean isCallbackConnection) throws IOException {
    HeapDataOutputStream hdos = new HeapDataOutputStream(32, KnownVersion.CURRENT);
    byte acceptanceCode = -1;
    try {
      hdos.writeByte(communicationMode.getModeNumber());
      if (overrideClientVersion > 0) {
        // for testing
        VersioningIO.writeOrdinal(hdos, overrideClientVersion, true);
      } else {
        VersioningIO.writeOrdinal(hdos,
            communicationMode.isWAN() ? KnownVersion.CURRENT_ORDINAL
                : currentClientVersion.ordinal(),
            true);
      }

      hdos.writeByte(replyCode);
      if (ports != null) {
        hdos.writeInt(ports.size());
        for (String port : ports) {
          hdos.writeInt(Integer.parseInt(port));
        }
      } else {
        hdos.writeInt(readTimeout);
      }
      // we do not know the receiver's version at this point, but the on-wire
      // form of InternalDistributedMember changed in 9.0, so we must serialize
      // it using the previous version
      DataOutput idOut = new VersionedDataOutputStream(hdos, KnownVersion.GFE_81);
      DataSerializer.writeObject(id, idOut);

      byte[] overrides = getOverrides();
      for (final byte override : overrides) {
        hdos.writeByte(override);
      }

      if (isCallbackConnection || communicationMode.isWAN()) {
        if (isCallbackConnection && multiuserSecureMode && !communicationMode.isWAN()) {
          hdos.writeByte(SECURITY_MULTIUSER_NOTIFICATIONCHANNEL);
          hdos.flush();
          dos.write(hdos.toByteArray());
          dos.flush();
        } else {
          writeCredentials(dos, dis, p_credentials, ports != null, member, hdos);
        }
      } else {
        String authInitMethod = system.getProperties().getProperty(SECURITY_CLIENT_AUTH_INIT);
        acceptanceCode = writeCredential(dos, dis, authInitMethod, ports != null, member, hdos);
      }
    } finally {
      hdos.close();
    }
    return acceptanceCode;
  }
client-to-server handshake. Nothing is sent to the server prior to invoking this method.
geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientSideHandshakeImpl.java