Expand description
async-send-fd is a library for sending and receiving Unix file descriptors over async UnixStream connections. You can either transfer
- RawFd;
- Tokio UnixStream if
tokio
feature enabled; - or Smol UnixStream if
smol
feature enabled;
§Examles
See test_smol_stream.rs or test_tokio_stream.rs for code examples.
§Creating a Tokio 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 makes it automatically if created using UnixStream::from(Async::new(stream))
§Transfering socket pair ownership
Sending a descriptor doesn’t close the local copy, which leads to having the socket being opened by the sender until it shuts down. If you want socket pair receivers to detect peer shutdown, you have to close local sockets after sending them.
Use UnixStream::poll_shutdown() for Tokio streams, or UnixStream::shutdown() for Smol.
§Features
tokio
- for Tokio supportsmol
- for Smol support
Traits§
- Async
Recv Fd - A trait to receive raw file descriptors
- Async
Recv Smol Stream - A trait to receive raw file descriptors
- Async
Recv Tokio Stream - A trait to receive raw file descriptors
- Async
Send Fd - A trait to send raw file descriptors
- Async
Send Smol Stream - A trait to send raw file descriptors
- Async
Send Tokio Stream - A trait to send raw file descriptors