I followed the Apple instructions carefully.
guard let multicast = try? NWMulticastGroup(for:[ .hostPort(host: "224.0.0.251", port: 5353) ]) else { NSLog("ERROR"); return }
let group = NWConnectionGroup(with: multicast, using: .udp)
group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in
NSLog("Received message from \(String(describing: message.remoteEndpoint))")
}
group.start(queue: .main)
However when I run this code I get the following error :
[49: Can't assign requested address]
The platform is iOS 14.2 and the problem persists if I run the program on a real device or through the simulator.
I have the com.apple.developer.networking.multicast entitlement and it is correctly configured.
I tried with various IP addresses (IPV4 and IPV6) and various ports, without any results.