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

#211 in Rust patterns

Download history 348/week @ 2024-01-18 276/week @ 2024-01-25 92/week @ 2024-02-01 317/week @ 2024-02-08 351/week @ 2024-02-15 339/week @ 2024-02-22 361/week @ 2024-02-29 282/week @ 2024-03-07 501/week @ 2024-03-14 413/week @ 2024-03-21 480/week @ 2024-03-28 367/week @ 2024-04-04 551/week @ 2024-04-11 392/week @ 2024-04-18 539/week @ 2024-04-25 432/week @ 2024-05-02

1,979 downloads per month
Used in 9 crates (5 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–16MB
~181K SLoC