-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnixStream / UnixDatagram requires API for sending packet with FDs #2975
Comments
Would #2903 solve your issue? |
Yes, it will. But that would require me to rewrite the whole UdpSocket. |
Are the functions in question available in mio? If not, open an issue there. |
Nope. Ok. |
Interesting point: the standard library has an open PR rust-lang/rust/pull/69864 for adding this functionality. I copied the functionality to the tokio-seqpacket crate, but I don't believe it's possible to update tokio-seqpacket crate to tokio 0.3.0 until #2903 is merged. It would make sense to stay close to the API that will be in the standard library. The initial PR does not allow external libraries to use the exact same mechanism since some important parts are not public. But the author was supportive of making that possible in a follow-up PR, so on the long term a large chunk of this could be done by |
I've been struggling with a way to send an fd as well. My original thought was just to use My current workaround, which seems to be doing the trick, although I haven't tested it extensively yet:
It would be great to have a built in way of sending the socket. But it also feels like it would make sense to be able to temporarily disassociate the UnixStream if we need to work with the underlying socket directly. |
I have implemented a crate to do this: fd-queue which I am currently trying to upgrade to tokio v0.3. The pre-release published version of the crate works with tokio v0.2.21. I did essentially have to rewrite the whole The upgrade to tokio v0.3 currently delayed a bit while I think up a workaround for #3068. |
I"m generally fine adding new APIs to the socket types. Somebody should propose these. We are also working to add fns to wait for readiness on all the socket types. This is tracked in #2968. |
That PR has been added to 1.50.0 milestone 6 days ago. |
What are the details of the API that std is stabilizing for this? |
I'm not familiar with Rust stabilization, but here are the related docs I've found:
|
Once the methods have been fully stabilized in std, I find it very likely that we would accept a PR that adds methods to Tokio that mirror std's design. |
@Darksonn I am the author of the PR, as soon as the API is the stabilized, I planned to implement it for |
It's worth mentioning that the new |
I would like to implement a version of UdpSocket based on socket2::Socket, as I want to use the method socket2::Socket::send_to_vectored() The following declaration fails, as PollEvened and IoSource are not exported by crates tokio and mio mod udp2 {
pub struct UdpSocket {
io: tokio::io::PollEvented<mio::IoSource<socket2::Socket>>,
}
} I need this declaration to be able to implement the following impl UdpSocket {
...
async fn send_to_addr_vectored(&self, bufs: &[IoSlice<'_>], target: SocketAddr) -> io::Result<usize> {
self.io
.registration()
.async_io(Interest::WRITABLE, || self.io.send_to_vectored(bufs, &SockAddr::from(target)))
.await
}
...
} AFAICS, if the following symbols would be exported tokio::PollEvented and mio:IoSource, the framework would be open for external IO entities. Any comments are welcome. |
The native socket impl in rustlib is supporting Socket::sendmsg. So it would be possible to implement the functionality UdpSocket::send_to_vectored(), first provided in API of rustlib:std::net, then in mio and finally in tokio::net To start with, I did a first pitch in rustlib. (WIP), implementing UdpSccket::send_to_vectored( iovec, dst) |
The |
Is your feature request related to a problem? Please describe.
Since v0.3
PollEvented
is in public APIs, I couldn't make one by myself.Describe the solution you'd like
An additional function on
UnixStream
/UnixSocket
, such assend_with_fds
that callslibc::sendmsg
andrecv_with_fds
callslibc::recvmsg
internally.Describe alternatives you've considered
AsyncFd
?PollEvented
?The text was updated successfully, but these errors were encountered: