Crates.io | telnet |
lib.rs | telnet |
version | 0.2.2 |
source | src |
created_at | 2017-12-22 13:06:23.958194 |
updated_at | 2024-10-06 11:47:49.12383 |
description | A simple implementation of telnet protocol. |
homepage | https://github.com/SLMT/telnet-rs |
repository | https://github.com/SLMT/telnet-rs |
max_upload_size | |
id | 44032 |
size | 38,483 |
A simple Telnet implementation.
use telnet::{Telnet, Event};
fn main() {
let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
.expect("Couldn't connect to the server...");
loop {
let event = telnet.read().expect("Read error");
if let Event::Data(buffer) = event {
// Debug: print the data buffer
println!("{:?}", buffer);
// process the data buffer
}
}
}
use telnet::{Telnet, Event};
fn main() {
let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
.expect("Couldn't connect to the server...");
loop {
let event = telnet.read_nonblocking().expect("Read error");
if let Event::Data(buffer) = event {
// Debug: print the data buffer
println!("{:?}", buffer);
// process the data buffer
}
// Do something else ...
}
}
use telnet::Telnet;
fn main() {
let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
.expect("Couldn't connect to the server...");
let buffer: [u8; 4] = [83, 76, 77, 84];
telnet.write(&buffer).expect("Read error");
}