1 unstable release
0.1.0 | Feb 12, 2021 |
---|
#24 in #expect
22KB
308 lines
udplite
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.
Supported operating systems
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)
mio integration
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)
)
Minimum supported Rust version
The minimum supported Rust version is 1.36.
Older versions might currently work, but I plan to use std::io::IoSlice
.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
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.
Dependencies
~0–470KB