3

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.

1
  • did you ever get a result on this? Commented Jan 16, 2021 at 2:35

1 Answer 1

4

I have contacted Apple DTS (Developer Technical Support) with the exact same question as you.

After investigating with the technician, we were able to conclude that even though we got this error message along with two others, the multicast still worked. More specifically, these are the three exact errors that we both got:

MulticastTest[49964:2029188] [] nw_listener_socket_inbox_create_socket setsockopt SO_NECP_LISTENUUID failed [2: No such file or directory]
MulticastTest[49964:2029188] [] nw_listener_socket_inbox_create_socket IP_DROP_MEMBERSHIP 224.0.0.1:28650 failed [49: Can't assign requested address]
     [NWConnectionGroup][state] group entered state waiting(POSIXErrorCode: Network is down)

For me, the reason why my original project was not working is due to the fact that the .entitlement file was never included in the build settings in XCode even though everything else was configured correctly. This wasn't ever mentioned in the instructions on how to properly set up the multicast entitlement found here: https://developer.apple.com/forums/thread/663271.

You can find both mine and the technician's working udp multicast projects here: https://github.com/richardwei6/Swift-Native-UDP-Multicast-Testing

This does answer your question but may not entirely fix your issue. However, it is worth a look.

Hope this helped!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.