Expose the async_io
function on socket/streams just like try_io
#5417
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-net
Module: tokio/net
Is your feature request related to a problem? Please describe.
I'm working on an async PTP network stack in Rust. I need to ask the kernel for timestamp information of received UDP packets.
The Tokio API doesn't support that directly, but I can make my own syscalls. I need to do that in an async fashion though.
Describe the solution you'd like
Internally, all async UDP socket APIs use the internal
self.io.registration().async_io()
function to do their syscalls efficiently.I'd like to get access to that from the outside as well so I can plug in my own syscalls.
This has been done before with the very similar
try_io
function.Describe alternatives you've considered
Initially I awaited the
readable
function on the UDP socket after which I made the syscall: hereHowever, that just always returns immediately. I think that's because the event isn't cleared because I was making my own syscall and didn't use one of Tokio's APIs.
The only alternative I can see is to simply do the syscall in a loop until it returns ok and just do a millisecond of sleep when it returns
WouldBlock
. But this is obviously not very elegant.Additional context
I have already made a PR #5416 for the UDP socket before I realized that the
try_io
function was defined on more types than just the UDP socket.If I get the go-ahead on this issue, I can update the PR so the
async_io
function is present for all types that already implementtry_io
.The text was updated successfully, but these errors were encountered: