commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rory Winston <rwins...@eircom.net>
Subject Re: TelnetClient problem?
Date Tue, 05 Dec 2006 23:35:36 GMT
Hi Daniel

This is handled in TelnetClient::_connectAction(). The output stream is 
wrapped in a ToNetASCIIOutputStream, which replaces all \n with \r\n. A 
quick fix for your serial blackbox system may (I havent tried this) be 
to replace the line

__output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));

with

__output = new BufferedOutputStream(new TelnetOutputStream(this));



protected void _connectAction_() throws IOException
    {
        super._connectAction_();
        InputStream input;
        TelnetInputStream tmp;

        if (FromNetASCIIInputStream.isConversionRequired())
            input = new FromNetASCIIInputStream(_input_);
        else
            input = _input_;


        tmp = new TelnetInputStream(input, this, readerThread);
        if(readerThread)
        {
            tmp._start();
        }
      .....
        __input = new BufferedInputStream(tmp);
        __output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));
    }

We could make this configurable in some way if necessary.
Rory

Daniel Wikman wrote:
> Hi all!
>
> I wonder if someone has seen this and know a "cure" for this behaviour. I wrote a program
based 
> on the commons.net TelnetClient class. When using the program towards a Unix or Linux
box 
> directly everything works fine, but when using telnet towards a serial blackbox, I always
get an 
> extra newline added when writing commands (it seems like TelnetClient or the underlying
stream 
> makes line terminations a la windows... The fun part is that if I make my own TelnetClient
program 
> based on Java.util.ProcessBuilder it works just fine. I'd really like to make my program
independent 
> of the "/usr/bin/telnet" to make it work on windows platform as well. Does anyone know
what 
> option that controls this in TelnetClient? 
>
> BR
>
> /Daniel 
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message