I forgot to mention that my app has a direct connect method for when broadcast discovery doesn’t work on a user’s network. In this case the user enters the IP address of the PC running the server and the port to connect on. For the small number of users that can no longer connect post iOS 16 update this mode isn’t working either. So perhaps I was wrongly focusing on the broadcast aspect of it?
I’m not sure I know enough to answer all your questions. Part of the idea of using Unity with Lidgren was that I wouldn’t have to know about the nitty gritty details of each platform. It has worked since I ported the app to iOS in 2018 ¯_(ツ)_/¯
While digging into Lidgren I can see in direct connect mode it still binds to the LocalAddress configuration parameter that I leave at the default value of IPAddress.Any. Port is also left at 0.
When bound it takes any free port usually somewhere above 40000.
var ep = (EndPoint)new NetEndPoint(localAddress, reBind ? m_listenPort : m_configuration.Port);
m_socket.Bind(ep);
When sending the following code is hit:
int bytesSent = m_socket.SendTo(data, 0, numBytes, SocketFlags.None, targetCopy);
In direct mode the targetCopy has the IP and port as entered by the user. Default port of my server is 9999 but can be configured to anything valid and free.
When using discover mode a discovery message is first sent to "255.255.255.255:9999" after connection is established the targetCopy variable sends to the specific end point found eg: "192.168.188.46:9999".
So as Lidgren gives me the LocalAddress parameter to bind to a specific interface would the possible solution be to find the address of the correct adapter and set it to that? But as I think I’ve seen mentioned there is no way to ensure we can get the address of the primary interface?
I’ll have to look at how much work it is to integrate Bonjour into the current app if that is the best way forward.