4 stable releases

1.2.0 May 22, 2024
1.1.0 May 13, 2024
1.0.1 Apr 8, 2024

#2255 in Asynchronous

Download history 31/week @ 2025-10-25 14/week @ 2025-11-01 13/week @ 2025-11-08 17/week @ 2025-11-15 30/week @ 2025-11-22 14/week @ 2025-11-29 196/week @ 2025-12-06 167/week @ 2025-12-13 75/week @ 2025-12-20 95/week @ 2025-12-27 150/week @ 2026-01-03 14/week @ 2026-01-10 22/week @ 2026-01-17 27/week @ 2026-01-24 15/week @ 2026-01-31 4/week @ 2026-02-07

69 downloads per month
Used in 12 crates (3 directly)

MIT license

13KB
194 lines

async-send-fd

A library for sending and receiving Unix file descriptors over async UnixStream connections.

Crates.io MIT licensed Build Status

Overview

The crate is a library for sending and receiving Unix file descriptors over Tokio or Smol UnixStream connections. You can send RawFd or UnixStream using provided interfaces.

See test_smol_stream.rs or test_tokio_stream.rs for code examples.

Creating tokio::net::UnixStream from RawFd

If you make a Tokio UnixStream from a raw file descriptor made by an OS call (e.g. UnixStream::pair), you must make it set_nonblocking(true), otherwise receivers scheduler will block writing into the socket ⚠️

Smol UnixStream does it automatically if created using UnixStream::from(Async::new(stream))

Transfering socket pair ownership

Note: the library closes Tokio stream if sent into another process.

Features

  • tokio - for Tokio support
  • smol - for Smol support

Dependencies

~2–14MB
~152K SLoC