commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Seguin" <>
Subject problem with RCommandClient
Date Tue, 29 Oct 2002 20:40:54 GMT

I'm trying to use RCommandClient as an rsh client.  it seems to be
working fine, except for when I want to pipe input to a remote process
through the output stream retrieved from
RCommandClient.getOutputStream().  the problem is that I can't send and
EOF to the the remote process by closing this stream, because that
results in the socket getting closed.  so the remote process never
completes - it hangs waiting for an EOF - or it ends when I close the
stream, but I can't read its output because the socket gets closed.
rock and a hard place, so to speak :)

I can "fix" this by subclassing RCommandClient and returning a an output
stream proxy that actually does a Socket.shutdownOutput() rather than
OutputStream.close() (see code below), but this seems like something
that ought to work out of the box.  I am just missing something?


--- workaround class ---

    class Rsh
        extends RCommandClient
        class OutputProxy extends OutputStreamProxy
            private Socket mySocket;
            OutputProxy(OutputStream target, Socket socket)
                mySocket = socket;
            public void close()
                throws IOException

        OutputStream myOutput;


        public OutputStream getOutputStream()
            if (myOutput == null)
                myOutput = new OutputProxy(_output_, _socket_);
            return myOutput;

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message