Reputation: 63
I've got a Telnet Client defined as:
TelnetClient telnet = new TelnetClient();
telnet.connect(server, port);
I then get the inputstream:
InputStream in = telnet.getInputStream();
and then try to read stuff on it, in a loop:
while (true) {
int TEST = in.read();
}
everything seems to go fine as I receive the "text" part of the input... but I'm missing the (very important for me!) leading bytes. Here is a snoop of what I see going on the port:
64: a88f ffff 3034 3131 3032 3030 3030 3030 ¨...041102000000
80: 3030 322e 3031 3131 2e36 2e34 2020 3135 002.0111.6.4 15
96: 2e39 2e33 2020 3030 3132 30 .9.3 00120
notice the "ffff": that's the leading part I need (everything before is garbage: part of the TCP communication).
However, when printing my "TEST" variable, I only see the "041102...etc".
I've tried using BOMInputStream too, but I can't get it either.
=> would you have any idea on how I can receive those ?
Thanks for your help !
Upvotes: 0
Views: 321
Reputation: 23321
You should be just using Socket
instead of TelnetClient
if you really want to see all of the data.
Upvotes: 1
Reputation: 719336
The input stream provided by a TelnetClient
instance is only going to provide the data characters. Telenet protocol signalling stuff will have been filtered out by the TelnetClient
code.
If you want to get hold of the signalling information, options, etcetera, you will need to use other methods in the TelnetClient
API. There are a variety of approaches you could possibly try. For example, you could register an option handler, or a notification handler, or you could register a "spy stream".
Upvotes: 2