27 releases (breaking)
0.18.0 | Nov 26, 2022 |
---|---|
0.16.0 | Jun 16, 2022 |
0.15.0 | Mar 16, 2022 |
0.13.0 | Dec 16, 2021 |
0.6.1 | Mar 4, 2021 |
#226 in Rust patterns
126 downloads per month
Used in 6 crates
(4 directly)
46KB
1K
SLoC
This crate wraps socketpair
with AF_UNIX
platforms, and emulates this
interface using CreateNamedPipe
on Windows.
It has a "stream" interface, which corresponds to SOCK_STREAM
and
PIPE_TYPE_BYTE
, and a "seqpacket" interface, which corresponds to
SOCK_SEQPACKET
and PIPE_TYPE_MESSAGE
.
Example
let (mut a, mut b) = socketpair_stream()?;
writeln!(a, "hello world")?;
let mut buf = [0_u8; 4096];
let n = b.read(&mut buf)?;
assert_eq!(str::from_utf8(&buf[..n]).unwrap(), "hello world\n");
Support for async-std and tokio is temporarily disabled until those crates contain the needed implementations of the I/O safety traits.
Dependencies
~0.3–6.5MB
~109K SLoC