| Crates.io | socketpair |
| lib.rs | socketpair |
| version | 0.19.8 |
| created_at | 2021-01-12 20:26:35.225135+00 |
| updated_at | 2025-05-15 16:50:58.916236+00 |
| description | Cross-platform socketpair functionality |
| homepage | |
| repository | https://github.com/sunfishcode/socketpair |
| max_upload_size | |
| id | 341061 |
| size | 117,543 |
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.
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.