I am using the TelnetClient from commons-net 3.3 in JDK 8. When I try to
receive xmodem data over a telnet session, some bytes do not make it
through to my code.
Example:
The remote device sends this (confirmed using windows network monitor):
01 01 FE [...] C0 00 FF FF FF 00 00 00 00 27 27 00 [...] (133 byte
xmodem-crc packet)
However, from the telnet client, I get this:
01 01 FE [...] C0 00 FF 00 00 00 27 27 00 [...] (130 bytes total)
>From what I have read, this is related to NVT. It looks like it is
converting [FF FF] to [FF] (removing one byte), and just outright removing
[FF 00] (removing another two bytes for a total of three).
I tried using telnetClient.addOptionHandler(new
SimpleOptionHandler(TelnetOption.BINARY, true, true, true, true));, but
that did not change the data I received.
A sample of the code I used to discover the issue is attached. Is there a
way to get the TelnetClient to pass all data through?
TelnetClient telnetClient = new TelnetClient();
// Tried with and without the following OptionHandler:
//telnetClient.addOptionHandler(new SimpleOptionHandler(TelnetOption.BINARY,
true, true, true, true));
telnetClient.connect(ip,port);
telnetClient.setKeepAlive(true);
InputStream inputStream = telnetClient.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(inputStream));
PrintWriter printWriter = new PrintWriter(telnetClient.getOutputStream(),true);
// Authentication code removed
// Receive XModem data
// Send command to initiate XMODEM-CRC transfer
byte start = 0x43;
printWriter.write(start);
printWriter.flush();
// Enter loop to display received binary data
ByteArrayOutputStream collector = new ByteArrayOutputStream();
while(true){
collector.write(bufferedReader.read());
log.debug(Hex.encodeHexString(collector.toByteArray()));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]