Skip to content
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

Create UdpSocket method that exposes async_io #5416

Closed
wants to merge 2 commits into from

Conversation

diondokter
Copy link

Motivation

We're building a PTP library and need to be able to read timestamp information from received UDP packet. This is not possible with Tokio's APIs directly of course, so we have to make the specific syscall ourselves.

We're making our PTP stack async, so receiving a packet has to be async as well.

All async udp functions that need to send or receive use the private internal async_io function from the Registration. This isn't available to use from the outside while the polling version of this API is public (named try_io).

Solution

I made a new method just like the existing try_io that allows access to the inner API.
With this we can plug in our own syscall that can read the socket together with the options so a timestamp is returned.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Jan 31, 2023
@Darksonn
Copy link
Contributor

Can you open a feature request issue for this?

If we decide to add a convenience wrapper around try_io, then it would need to be added to all of our socket types - not just UdpSocket.

@diondokter
Copy link
Author

Can you open a feature request issue for this?

I will! I looked at TCP to see if it had that function and saw it didn't. However, looking more carefully I now see that e.g. stream and unix sockets also have that function.

@Darksonn
Copy link
Contributor

Darksonn commented Feb 9, 2023

I'm ok with adding this, but it would need to be added to all of our IO resources.

@Darksonn Darksonn marked this pull request as draft February 26, 2023 15:44
@amab8901 amab8901 mentioned this pull request Feb 27, 2023
@satakuma
Copy link
Member

Closing in favor of #5512.

@satakuma satakuma closed this Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-net Module: tokio/net
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants