Object requestToServer(final @NotNull HostAndPort address, final @NotNull Object request,
      final int timeout, final boolean replyExpected, final short serverVersionOrdinal,
      final @NotNull KnownVersion serverVersion, final @Nullable String debugVersionMessage)
      throws IOException, ClassNotFoundException {
    logger.debug("TcpClient sending {} to {}", request, address);

    final Socket sock = socketCreator.forCluster().connect(address, timeout, null, socketFactory);
    try {
      sock.setSoTimeout(timeout);
      try (final DataOutputStream out = createDataOutputStream(sock, serverVersion)) {
        sendRequest(out, serverVersionOrdinal, request);
        if (replyExpected) {
          try (final DataInputStream in = createDataInputStream(sock, serverVersion)) {
            if (debugVersionMessage != null && logger.isDebugEnabled()) {
              logger.debug(debugVersionMessage);
            }
            return receiveResponse(in, address);
          }
        } else {
          return null;
        }
      }
    } finally {
      try {
        if (replyExpected) {
          // Since we've read a response we know that the Locator is finished
          // with the socket and is closing it. Aborting the connection by
          // setting SO_LINGER to zero will clean up the TIME_WAIT socket on
          // the locator's machine.
          if (!sock.isClosed() && !socketCreator.forCluster().useSSL()) {
            sock.setSoLinger(true, 0);
          }
        }
        sock.close();
      } catch (Exception e) {
        logger.error("Error closing socket ", e);
      }
    }
  }
Send a request to a Locator

@param address The locator's address
@param request The request message
@param timeout Timeout for sending the message and receiving a reply
@param replyExpected Whether to wait for a reply
@return The reply, or null if no reply is expected. This may also return a null
        if we're unable to form a connection to the TcpServer before the given timeout elapses
@throws ClassNotFoundException if the deserializer throws this exception
@throws IOException if there is a problem interacting with the server
geode-tcp-server/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java