Crates.io | async-utp |
lib.rs | async-utp |
version | 0.8.0-alpha1 |
source | src |
created_at | 2021-05-20 12:16:49.452984 |
updated_at | 2021-05-20 12:16:49.452984 |
description | An async µTP (Micro/uTorrent Transport Library) library for Tokio |
homepage | https://github.com/Distributed-EPFL/tokio-utp |
repository | https://github.com/SonicFrog/tokio-utp |
max_upload_size | |
id | 399945 |
size | 194,153 |
An async Micro Transport Protocol library implemented in Rust.
The Micro Transport Protocol is a reliable transport protocol built over UDP. Its congestion control algorithm is LEDBAT, which tries to use as much unused bandwidth as it can but readily yields to competing flows, making it useful for bulk transfers without introducing congestion in the network.
The current implementation is somewhat incomplete, lacking a complete implementation of congestion
control. However, it does support packet loss detection (except by timeout) the
Selective Acknowledgment extension, handles unordered and duplicate packets and
presents a stream interface (UtpStream
).
This crate is experimental and contains many bugs. We strongly advice against using it in production environments. Contributions and fixes are welcome :)
To use tokio-utp
, add this to your Cargo.toml
:
[dependencies]
async-utp = "*"
The simplest example program would be:
use async_utp::UtpStream;
use tokio::task;
use std::io::Write;
fn main() {
// Connect to an hypothetical local server running on port 8080
let addr = "127.0.0.1:8080";
let (mut stream, driver) = UtpStream::connect(addr).await.expect("Error connecting to remote peer");
task::spawn(driver);
// Send a string
stream.write("Hi there!".as_bytes()).await.expect("Write failed");
// Close the stream
stream.close().await.expect("Error closing connection");
}
Check out the files under the "examples" directory for more example programs, or run them with cargo run --example <example_name>
.
drop
if not already closedThis library is distributed under similar terms to Rust: dual licensed under the MIT license and the Apache license (version 2.0).
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.