-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
A more useful UDP echo example #6737
Comments
@Zoxc For clarity in my own mind, for the example to be more realistic, you would want the first socket to be open as the "server" and bind to all interfaces, probably on a specified port: and then for the client, you would open a socket on another port, use |
That would run into problems since it reuses the port and seems inefficient. A better way would be following the |
Ok that’s what I thought you meant at first but then I saw the thing about the client not even checking if the response is from the same server and thought it might be an easier problem to solve than I first thought. I read that section of the blog, thanks. In terms of implementing new APIs, specifically it would be an API in Tokio/Mio to be able to get the CSMG Metadata from the underlying Linux/BSD/(Windows?) API? Is there an argument to iterate all interfaces and bind to each one individually in the example and then noting in the comments that this isn’t ideal for all use cases? That would at least open up the idea and leaves further reading up to the user. Or did you intend this issue to point out this as a limitation of Tokio and then track updating the example as a good “definition of done”. |
Yeah I think some replacement for
I was wondering if there was an easier way that I missed, but it doesn't appear so. I also noticed that there's a similar example on |
Yeah, I see the other example now and the potential problems with it. After a little digging it sounds like the "replacement" would be If we got an implementation of *just a matter - it's still messy in IPv4 but better in IPv6, and the example in the blog doesn't include Windows implementation I could imagine a few paths forward. Not sure if I love any of them:
At the very minimum, if it was decided to do nothing else, the example that uses wildcards should be changed, since it could fail silently. |
What about using the Rust implementation of Wireguard as a precedent for how to implement this? Basically make a Inside those functions you could do the CMSG work and when the UDPSocket is operating in that mode, it attaches that information to each incoming packet so that you can read it off the packet when sending a response. I guess then all that would be left is to implement a *I see the issue you opened in the Rust code base, feel free to carry this over there if you think it's a more appropriate issue to have the discussion. |
Here's some code demonstrating the issue, for anyone else coming along later: add a file in the
Example output:
We loop through all the IP addresses the server is hosting from but it always responds with the same default IP. |
It would be nice if the UDP echo server example was more realistic and allowed binding to any interface.
The current example doesn't constrain the reply to occur from the same IP it was received on which means it only works when bound to a specific IP.
The text was updated successfully, but these errors were encountered: