33 releases (19 breaking)

0.19.5 Mar 29, 2024
0.19.4 Dec 30, 2023
0.19.3 Jun 28, 2023
0.19.1 Mar 29, 2023
0.6.1 Mar 4, 2021

#177 in Rust patterns

Download history 1690/week @ 2024-11-01 2362/week @ 2024-11-08 2094/week @ 2024-11-15 2063/week @ 2024-11-22 1786/week @ 2024-11-29 2822/week @ 2024-12-06 884/week @ 2024-12-13 548/week @ 2024-12-20 558/week @ 2024-12-27 2645/week @ 2025-01-03 2744/week @ 2025-01-10 2206/week @ 2025-01-17 1861/week @ 2025-01-24 2627/week @ 2025-01-31 2069/week @ 2025-02-07 650/week @ 2025-02-14

7,549 downloads per month
Used in 14 crates (6 directly)

Apache-2.0…

48KB
1K SLoC

socketpair

Cross-platform socketpair functionality

Github Actions CI Status crates.io page docs.rs docs

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

~2–14MB
~190K SLoC