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

#163 in Rust patterns

Download history 2997/week @ 2024-10-01 1719/week @ 2024-10-08 1802/week @ 2024-10-15 1478/week @ 2024-10-22 1929/week @ 2024-10-29 1773/week @ 2024-11-05 2605/week @ 2024-11-12 1821/week @ 2024-11-19 1961/week @ 2024-11-26 2256/week @ 2024-12-03 1890/week @ 2024-12-10 914/week @ 2024-12-17 411/week @ 2024-12-24 1871/week @ 2024-12-31 2135/week @ 2025-01-07 2660/week @ 2025-01-14

7,144 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–13MB
~176K SLoC