UDP strange behaviour

I have an app in python that uses a UDP port. If I try to open more than one instance of the python app I get an error as it can’t have 2 python apps binding to the same port.
However if I have the python app running , using port 10222, then my xojo app will happily bind to that port, even though the python app already has it bound.
Xojo connects, detects that there is data there.
I’m trying to find out if there is an easy way to determine if there is a way that Xojo can determine that the port is already on use? and alert me rather than just binding, I was expecting an error to be raised…

using 2016 1.1 on windows 10
Hamish

Xojo UDP sockets call socket and bind when asked to listen. There’s no call to setopt for SO_REUSEADDR or SO_EXCLUSIVEADDRUSE before the bind. Microsoft’s documentation on using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE leads me to believe that this allows second socket’s bind succeed if it’s running as the same user (though it’s late and I could be misreading it).

Xojo does use SO_EXCLUSIVEADDRUSE for TCP sockets. I’m not sure if UDP sockets got overlooked or if there was some other reason, such as backwards compatibility, that drove the decision.

I don’t have a decent workaround for you, sadly. The only thing I can think of is to set up your own listening socket via declares to pre-flight things, but that would either have race conditions or break when this behavior changes.