Open j-santander opened 5 years ago
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?
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.
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