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

#166 in Rust patterns

Download history 1686/week @ 2024-08-15 2004/week @ 2024-08-22 1914/week @ 2024-08-29 2272/week @ 2024-09-05 1933/week @ 2024-09-12 1496/week @ 2024-09-19 2632/week @ 2024-09-26 2728/week @ 2024-10-03 1870/week @ 2024-10-10 1445/week @ 2024-10-17 1685/week @ 2024-10-24 1711/week @ 2024-10-31 1985/week @ 2024-11-07 2537/week @ 2024-11-14 1773/week @ 2024-11-21 1817/week @ 2024-11-28

8,405 downloads per month
Used in 13 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
~178K SLoC