LiteNetLib icon indicating copy to clipboard operation
LiteNetLib copied to clipboard

NetManager.SendBroadcast not working on iOS (Unity LTS 2022)

Open rubit0 opened this issue 1 year ago • 1 comments

In a local WiFi scenario, iOS devices can't discover each other via NetManager.SendBroadcast. This works just fine with Android, Android Meta Quest, macOS and PC. My code used to thrown this exception: System.Net.Sockets.SocketException: No route to host at System.Net.Sockets.Socket.SendTo But I updated to the latest version LiteNetLib and there are no more exceptions thrown, yet the issue prevails.

Here is the place where I call SendBroadcast. https://github.com/rubit0/PicoNet/blob/main/Packages/PicoNet/Runtime/PeerDiscoverySession.cs#L59

You can also pull the project via the Unity package manager into an empty unity project and load the demo which is a a basic chat program. Works great on all devices expect iOS to iOS.

Could it be that on iOS the app requires the com.apple.developer.networking.multicast entitlement? https://developer.apple.com/news/?id=0oi77447 And if so, are there any other ways to discover peers in the local wifi network?

Thanks in advance.

Library version: [1.2.0]

Framework: [Unity]

OS: [iOS]

rubit0 avatar Feb 27 '24 22:02 rubit0

Could it be that on iOS the app requires the com.apple.developer.networking.multicast entitlement?

Yes

And if so, are there any other ways to discover peers in the local wifi network?

If you have master server you can check that there peers from same IP but with different port - you can consider that this peers in local network

Or just send packets to local network to adresses from (example) 192.168.1.1 to 192.168.1.255

RevenantX avatar Feb 28 '24 09:02 RevenantX

https://developer.apple.com/forums/thread/663875 "The general rule is that sending or receiving multicast or broadcast traffic requires the multicast entitlement (com.apple.developer.networking.multicast)."

RevenantX avatar May 10 '24 08:05 RevenantX