| Crates.io | libutp-rs2 |
| lib.rs | libutp-rs2 |
| version | 0.1.4 |
| created_at | 2025-02-17 13:55:57.76583+00 |
| updated_at | 2025-08-02 10:18:44.998592+00 |
| description | Rust bindings for libutp |
| homepage | |
| repository | https://github.com/ikatson/libutp-rs2 |
| max_upload_size | |
| id | 1558937 |
| size | 55,746 |
Async Tokio library for uTP (uTorrent transport protocol) using C-based libutp under the hood.
Working and tested alternative to libutp-rs
use libutp_rs2::UtpUdpContext;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Server
let server_addr = "127.0.0.1:8001".parse()?;
let listener = tokio::spawn(async move {
let mut buf = String::new();
UtpUdpContext::new_udp(server_addr)
.await?
.accept()
.await?
.read_to_string(&mut buf)
.await?;
Ok::<_, anyhow::Error>(buf)
});
// Client
tokio::spawn(async move {
UtpUdpContext::new_udp("127.0.0.1:8002".parse()?)
.await?
.connect(server_addr)
.await?
.write_all(b"hello")
.await?;
Ok::<_, anyhow::Error>(())
});
println!("{}", listener.await.unwrap().unwrap());
Ok(())
}