tokio_udt/lib.rs
1/*!
2An implementation of UDP-based Data Transfer Protocol (UDT) based on Tokio primitives.
3
4UDT is a high performance data transport protocol. It was designed for data intensive
5applications over high speed wide area networks, to overcome the efficiency and fairness
6problems of TCP. As its names indicates, UDT is built on top of UDP and it provides both
7reliable data streaming and messaging services.
8
9
10# Usage
11
12## UDT server example
13
14Bind a port with [`UdtListener`]:
15
16```no_run
17use std::net::Ipv4Addr;
18use tokio::io::{AsyncReadExt, Result};
19use tokio_udt::UdtListener;
20
21#[tokio::main]
22async fn main() -> Result<()> {
23 let port = 9000;
24 let listener = UdtListener::bind((Ipv4Addr::UNSPECIFIED, port).into(), None).await?;
25
26 println!("Waiting for connections...");
27
28 loop {
29 let (addr, mut connection) = listener.accept().await?;
30 println!("Accepted connection from {}", addr);
31 let mut buffer = Vec::with_capacity(1_000_000);
32 tokio::task::spawn({
33 async move {
34 loop {
35 match connection.read_buf(&mut buffer).await {
36 Ok(_size) => {}
37 Err(e) => {
38 eprintln!("Connnection with {} failed: {}", addr, e);
39 break;
40 }
41 }
42 }
43 }
44 });
45 }
46}
47```
48
49## UDT client example
50
51Open a connection with [`UdtConnection`]
52
53```no_run
54use std::net::Ipv4Addr;
55use tokio::io::{AsyncWriteExt, Result};
56use tokio_udt::UdtConnection;
57
58#[tokio::main]
59async fn main() -> Result<()> {
60 let port = 9000;
61 let mut connection = UdtConnection::connect((Ipv4Addr::LOCALHOST, port), None).await?;
62 loop {
63 connection.write_all(b"Hello World!").await?;
64 }
65}
66```
67*/
68mod ack_window;
69mod common;
70mod configuration;
71mod connection;
72mod control_packet;
73mod data_packet;
74mod flow;
75mod listener;
76mod loss_list;
77mod multiplexer;
78mod packet;
79mod queue;
80mod rate_control;
81mod seq_number;
82mod socket;
83mod state;
84mod udt;
85
86pub use configuration::UdtConfiguration;
87pub use connection::UdtConnection;
88pub use listener::UdtListener;
89pub use rate_control::RateControl;
90pub use seq_number::SeqNumber;
91
92#[cfg(doctest)]
93doc_comment::doctest!("../README.md");