SLMT / telnet-rs

A simple implementation of Telnet in Rust.
MIT License
44 stars 20 forks source link

Reading cause split data randomly #16

Open TheYkk opened 3 years ago

TheYkk commented 3 years ago

Hi, I am using 0.1.4 version of telnet-rs .

Error

The telnet rs only read first part of data

How to fix

https://github.com/SLMT/telnet-rs/blob/80eddf03029dcfd60c107409b011debc7695db3b/src/lib.rs#L168 If we can change read method to read_to_end , we will able to read all of tcp parts.

Client code

let mut stream = Telnet::connect(("whois.nic.uno", 43), 1024 * 1024).expect("Couldn't connect to the server...");
stream.write("kaan.uno \n".as_bytes()).expect("Write Error");

// sleep(Duration::from_secs(1));

let event = stream.read().expect("Read Error");
if let TelnetEvent::Data(buf) = event.borrow() {
println!("{}", from_utf8(&buf).unwrap()); // Sometimes full data some time half of data
}

Half data

image

Full data

image

Tcp data

image

SLMT commented 3 years ago

Thanks for your report. We will look into it.