Crate async_send_fd

Source
Expand description

async-send-fd is a library for sending and receiving Unix file descriptors over async UnixStream connections. You can either transfer

§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 support
  • smol - for Smol support

Traits§

AsyncRecvFd
A trait to receive raw file descriptors
AsyncRecvSmolStream
A trait to receive raw file descriptors
AsyncRecvTokioStream
A trait to receive raw file descriptors
AsyncSendFd
A trait to send raw file descriptors
AsyncSendSmolStream
A trait to send raw file descriptors
AsyncSendTokioStream
A trait to send raw file descriptors