This repository was archived by the owner on Aug 15, 2022. It is now read-only.
Improve selection of local UDP port for client #306
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm developing a project where multiple clients will be created on the same server.
What I've found is that as I launch each client, they will be just replace the previous one in the server, because clients are tracked by IP and source port and all the clients launched share the same port.
I've noticed that the existing UDPClient.cs code tries to select one local port. However a different one is only attempted if there's an exception.
I tried to add some additional checks (based on this answer on SO: https://stackoverflow.com/a/5879681/308705) and it now works (at least for me).
Hoping it will help someone else, I'm submitting this PR.
Cheers