class RpcStreamConnection extends RpcConnection {

    void calculatePreambleBytesAndSendtoDownstream(
            @Nonnull final RpcPacketSupplier argsSupplier) throws ConnectionException {
        byte[] sendBytes = argsSupplier.sendBytes();
        int sendPos = argsSupplier.sendPos();

        byte[] preambleBytes = RpcPacketPreamble
                .constructPreamble(sendPos - RpcPacketPreamble.RPC_PREAMBLE_SIZE).marshalAsBytes();
        System.arraycopy(preambleBytes, 0, sendBytes, 0, preambleBytes.length);
        try {
            topOutputStream.write(sendBytes, 0, sendPos);
            topOutputStream.flush();
            stats.streamSends.incrementAndGet();
            stats.totalBytesSent.getAndAdd(sendPos);
            stats.packetsSent.incrementAndGet();
            if (stats.largestRpcPacketSent.get() < sendPos) {
                stats.largestRpcPacketSent.set(sendPos);
            }
        } catch (IOException exc) {
            Log.exception(exc);
            StringBuilder message = new StringBuilder();
            if (exc instanceof SocketTimeoutException && secure) {
                message.append(MessageFormat.format(
                        "SSL connect to ssl:{0}:{1,number,#} failed.\nRemove SSL protocol prefix.\n",
                        hostName, hostPort));
            } else {
                message.append("Unable to send command to Perforce server: ");
            }
            message.append(exc.getMessage());
            throwConnectionException(exc, message.toString());
        }
    }

    public  RpcStreamConnection(String serverHost, int serverPort, Properties props,
                               ServerStats stats, P4Charset p4Charset, boolean secure);
    private  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, P4Charset p4Charset, Socket socket, boolean secure);
    private  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, P4Charset p4Charset, Socket socket, RpcSocketPool pool, boolean secure);
    public  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, P4Charset p4Charset, Socket socket, RpcSocketPool pool, boolean secure,
            String rsh);

}