Same problem, here is our code, same problem with GCDAsyncUdpSocket library.
If i use an other port it works.
class ViewController: UIViewController {
var group: NWConnectionGroup!
override func viewDidLoad() {
super.viewDidLoad()
guard let multicast = try? NWMulticastGroup(for: [ .hostPort(host: "224.0.0.251", port: 55555) ])
else { fatalError("") }
group = NWConnectionGroup(with: multicast, using: .udp)
group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in
print("MESSAGE: \(String(describing: message.remoteEndpoint))")
}
group.stateUpdateHandler = { (newState) in
print("STATUS: \(String(describing: newState))")
}
group.start(queue: .main)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
send()
}
func send(){
let groupSendContent = Data("helloAll".utf8)
group.send(content: groupSendContent) { error in
if let err = error{
print("Send complete with error \(err)")
}
}
}
}
Topic:
Code Signing
SubTopic:
Entitlements
Tags: