Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Improve selection of local UDP port for client #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

j-santander
Copy link

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

@phalasz
Copy link
Contributor

phalasz commented Aug 20, 2019

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?

Copy link
Member

@Crazy8ball Crazy8ball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes per comment above.

@notjuanortiz
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants