@eskimo thanks for the reply - yes I confirmed that after changing the port number to 19000 instead of 1900 (on both my Client iOS App and tvOS server app) it does indeed work correctly. And it works correctly on the tvOS simulator using the correct SSDP port (1900), and I can see the port bound in lsof when it's running:
MyTVApp 76639 ikura 5u IPv4 0x5f8914619e22755b 0t0 UDP *:ssdp
Here's my code block where the bind fails, it's using GCDAsyncSockets:
// MARK: Socket Setup
let multicastSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: DispatchQueue.main)
multicastSocket.setIPv6Enabled(false)
do {
try multicastSocket.enableReusePort(true)
try multicastSocket.bind(toPort: 1900) // On AppleTV 4K tvOS14.6 this throws with 'Address in Use' error
try multicastSocket.joinMulticastGroup("239.255.255.250")
try multicastSocket.enableBroadcast(true)
try multicastSocket.beginReceiving()
} catch {
multicastSocket.close()
DispatchQueue.main.async {
for observer in self.observers {
observer.multicastSocketInitialisationFailed(error: error)
}
}
}
self.multicastSocket = multicastSocket