#io

socketpair

Cross-platform socketpair functionality

21 releases (13 breaking)

0.13.0 Dec 16, 2021
0.12.0 Nov 18, 2021
0.11.1 Nov 12, 2021
0.8.1 Jul 14, 2021
0.6.1 Mar 4, 2021

#423 in Rust patterns

Download history 41/week @ 2021-10-03 44/week @ 2021-10-10 9/week @ 2021-10-17 5/week @ 2021-10-24 8/week @ 2021-10-31 72/week @ 2021-11-07 41/week @ 2021-11-14 8/week @ 2021-11-21 35/week @ 2021-11-28 10/week @ 2021-12-05 50/week @ 2021-12-12 44/week @ 2021-12-19 10/week @ 2021-12-26 36/week @ 2022-01-02 17/week @ 2022-01-09

108 downloads per month
Used in 6 crates (4 directly)

Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT

46KB
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");

Dependencies

~0.2–4MB
~88K SLoC

>™ğa