Crates.io | udplite |
lib.rs | udplite |
version | 0.1.0 |
source | src |
created_at | 2021-02-12 22:44:23.35054 |
updated_at | 2021-02-12 22:44:23.35054 |
description | An idiomatic UDP-Lite wrapper, with optional mio integration |
homepage | |
repository | https://github.com/tormol/udplite |
max_upload_size | |
id | 354397 |
size | 53,097 |
A Rust library for using UDP-Lite sockets. (RFC 3828)
extern crate udplite;
let socket = udplite::UdpLiteSocket::bind("[::]:0").expect("Create UDP-Lite socket");
socket.set_send_checksum_coverage(Some(0)).expect("disable checksum coverage for payload");
socket.connect("localhost:7").expect("set destination");
socket.send(b"Hello UDP-Lite").expect("send datagram");
This crate is a work in progress.
UDP-Lite is only implemented by Linux and FreeBSD.
Whether Android supports it I'm not sure about: The kernel has the constants, but some of them are missing from bionic (the Android libc). (only IPPROTO_UDPLITE
is present)
The FreeBSD implementation also behaves strangely: sent packets that are not entirely covered completely by the checksum (UDPLITE_SEND_CSCOV
) seems to be discarded by the OS. (meanwhile such packets sent from Linux are received)
Like UDP sockets, UDP-Lite sockets can be registered with epoll / kqueue, and therefore used with mio. This feature is not enabled by default; enable it in Cargo.toml with:
[dependencies]
udplite = {version="0.1.0", features=["mio_07"]}
Also remember to enable nonblocking mode for the sockets. (UdpLiteSocket.set_nonblocking(true)
)
The minimum supported Rust version is 1.36.
Older versions might currently work, but I plan to use std::io::IoSlice
.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.