iOS 14 introduces multicast support in the Network framework in the form of NWMulticastGroup.
Following Apple's guide ( https://developer.apple.com/news/?id=0oi77447 ) I am trying to join the multicast group for SSDP using the following code:
However, it seems that the port is already in use by another application.
Now I have the following issues:
Following Apple's guide ( https://developer.apple.com/news/?id=0oi77447 ) I am trying to join the multicast group for SSDP using the following code:
Code Block swift let host = NWEndpoint.Host(ipFamily.ssdpGroupName) let multicastGroup = try NWMulticastGroup(for: [.hostPort(host: host, port: .ssdp)]) let ssdpGroup = NWConnectionGroup(with: multicastGroup, using: .udp) ssdpGroup.stateUpdateHandler = { newState in Logger.info("Reached new state: \(newState)") } ssdpGroup.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: false, handler: {[weak self] (message, content, isComplete) in Logger.info("SSDP message received, do something here...") }) ssdpGroup.start(queue: delegateQueue)
However, it seems that the port is already in use by another application.
Now I have the following issues:
It reaches the .ready state and then crashes, instead of reaching the error state...
Is there a way to configure the socket to allow socket reuse? This is important to prevent clashes with e.g. the Spotify app.
Is it possible to send a message to the multicast group from a different port? (destination port and source port are different)