Expand description
tokio-send-fd is a library for sending and receiving Unix file descriptors over tokio UnixStream connections. You can either transfer RawFd or UnixStream.
§Examles
See test_raw_fd.rs and test_tokio_stream.rs for examples.
§Creating UnixStream from RawFd
If you want to create tokio UnixStream from a raw file descriptor created by os’ UnixStream::pair call, you should make it set_nonblocking(true), otherwise tokio stream will block in async functions ⚠️
§Transfering socket pair ownership
Sending a socket of a socket pair doesn’t close the local copy, which leads to having the socket being opened until the sender is shut down. If you want counterparties to detect peer shutdown, you have to close socket pair right after sending a socket to a peer. Use close Posix call.
§Async trait disclaimer
The crate uses async-trait and because of this has a lot of extra lifetime parameters on the trait. Once async traits RFC is merged, dependency will be removed.
Traits§
- SendFd
- SendFd trait, use this extend UnixStream with sending and receiving functions