NetworkServiceDiscovery: multiple listeners on same machine

I have the following use case: a main application which can be running on the same machine or one in the network, and several smaller satellite applications which want to connect to the main one. I am currently investigating if NetworkServiceDiscovery can be a solution for that.

However I have the following problem:
With multiple listeners (AvailableServiceList instance) running on the same machine, only the first one will find the service, as the first one will block the second one to bind to the broadcast port.

With the following addition to the AvailableServiceList’s constructor I can make it work with several listeners on the same machine:

// AvailableServicesList constructor
    socket.setEnablePortReuse (true); // <--this
    socket.bindToPort (broadcastPort);

Is there a reason why the socket is not configured for port-reuse? I’ve tested this on macOS, so maybe it won’t work on other platforms?

1 Like

It doesn’t work on Windows (binding will succeed, but the second client still won’t receive anything)