https://github.com/slmt/telnet-rs
A simple implementation of Telnet in Rust.
https://github.com/slmt/telnet-rs
rust-library telnet
Last synced: 6 months ago
JSON representation
A simple implementation of Telnet in Rust.
- Host: GitHub
- URL: https://github.com/slmt/telnet-rs
- Owner: SLMT
- License: mit
- Created: 2017-10-09T15:01:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-14T14:47:04.000Z (8 months ago)
- Last Synced: 2025-04-04T09:44:53.143Z (6 months ago)
- Topics: rust-library, telnet
- Language: Rust
- Size: 84 KB
- Stars: 47
- Watchers: 4
- Forks: 21
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# telnet-rs
[](https://travis-ci.org/SLMT/telnet-rs)
[](./LICENSE)
[](https://crates.io/crates/telnet)
[](http://docs.rs/telnet)A simple Telnet implementation.
## Examples
### Blocking Reading
```rust
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
}
}
}
```### Non-Blocking Reading
```rust
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 ...
}
}
```### Writing
```rust
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");
}
```## TODOs
- reduce unnecessary data copy
- add coverage check
- add crate-level documentation