I have need to connect to an ancient piece of equipment using telnet. So I grab the one and only telnet crate https://crates.io/crates/telnet and try out the example code:
let mut telnet = Telnet::connect(("192.168.0.109", 23), 256)
.expect("Couldn't connect to the server...");
println!("Connected");
loop {
let event = telnet.read_nonblocking().expect("Read error");
match event {
TelnetEvent::Data(buffer) => {
// Debug: print the data buffer
println!("{:?}", String::from_utf8_lossy(&buffer));
// process the data buffer
},
_ => {}
}
}
And run it against a Raspberry Pi running telnetd.
Nothing happens.
Well, it connects and that is it. What I'm expecting is the Pi login prompt as I get when I telnet to it manually:
$ telnet 192.168.0.109
Trying 192.168.0.109...
Connected to 192.168.0.109.
Escape character is '^]'.
Raspbian GNU/Linux 10
raspberrypi login:
Tried the blocking read as well. Same result.
As a random experiment I reduce the buffer size from 256 to 1. And then I get this:
Connected
"�"
"\u{18}"
"�"
" "
"�"
"#"
"�"
"\'"```
Which does not look like what I want. Not in hex either:
[fd]
[18]
[fd]
[20]
[fd]
[23]
[fd]
[27]
Any suggestions?