| Crates.io | mptcp |
| lib.rs | mptcp |
| version | 0.1.5 |
| created_at | 2024-04-22 17:26:07.306903+00 |
| updated_at | 2024-05-06 11:24:53.872199+00 |
| description | A helper crate to create MPTCP sockets |
| homepage | |
| repository | https://github.com/gdetal/mptcp-rs |
| max_upload_size | |
| id | 1216364 |
| size | 107,720 |
A helper crate to create Multipath TCP (MPTCP) sockets.
The crate currently supports:
std::net::TcpStream and std::net::TcpListenerTo create an MPTCP stream:
use mptcp::MptcpStreamExt;
let stream = TcpStream::connect_mptcp("www.google.com:443").unwrap();
The connect_mptcp method handles falling back to a TCP socket in case MPTCP
is not available on the system. Use connect_mptcp_force if you require to
use MPTCP.
To create an MPTCP listener:
use mptcp::MptcpListenerExt;
let listener = TcpListener::bind_mptcp("localhost:8080").unwrap();
Similarly to the Stream. The bind_mptcp method handles falling back to a
TCP socket in case MPTCP is not available on the system. Use bind_mptcp_force
if you require to use MPTCP.
Use the into_socket() to retrieve to retrieve a TcpStream or TcpListener to
be reused in existing libraries. MPTCP sockets provides the same API as TCP
sockets.
You can also check whether a TcpStream uses an underlying MPTCP socket using:
use mptcp::{MptcpExt, MptcpStatus};
let stream : TcpStream = ...;
println!("stream uses mptcp: {}", matches!(stream.mptcp_status(), MptcpStatus::Mptcp { .. }));
Tokio support can be enabled via feature: tokio. Usage is similar for std lib
by importing mptcp::tokio::MptcpStreamExt.
This project is licensed under the MIT License.