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
Open
j-santander wants to merge 1 commit intoBeardedManStudios:masterfrom
Open
Improve selection of local UDP port for client#306j-santander wants to merge 1 commit intoBeardedManStudios:masterfrom
j-santander wants to merge 1 commit intoBeardedManStudios:masterfrom
Conversation
Contributor
|
Interesting. I have not ran into the issue you are fixing here although I have multiple clients running on the same machine where the server is when I'm testing. Would you be able to provide a barebones project as well so we can validate your fix? |
Crazy8ball
suggested changes
Oct 24, 2019
Member
Crazy8ball
left a comment
There was a problem hiding this comment.
Requesting changes per comment above.
|
There should be an error thrown when selecting ports in the rare case where all ports are in use. Given there's about 65535 ports available it is rare but, it should be accounted for. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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