I cannot get UDP multicast over IPv6 to work. The platform on which I'm trying to do this is iOS (using Swift). I have a GCDAsyncUdpSocket
and configure it like this:
self.socket!.setIPv4Enabled(false)
self.socket!.setIPv6Enabled(true)
do {
try self.socket!.bindToPort(Announcement.ipv6BroadcastPort, interface: "en0")
}
catch let error {
print("bind failed: \(error)")
throw error
}
do {
try self.socket!.joinMulticastGroup("ff32::5222", onInterface: "en0")
}
catch let e {
print("join multicast failed: \(e)")
}
After that, I try to send some data to a multicast address:
socket.sendData(data, toHost:"ff32::5222", port: 21026, withTimeout: 5, tag: 0)
At that point, when stepping through the GCDAsyncUDPSocket code, I end up in a call to sendto
in the method doSend
(line 3919). This call returns -1 and the error is "no route to host". I'm running this in the iOS simulator. When I enumerate all available network interfaces, I get this:
Name: lo0
Address: Optional("::1ebc:680b:100:0")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: lo0
Address: Optional("::2bc:680b:100:0")
Family: NetUtils.Interface.Family.ipv4
Supports multicast: true
Name: lo0
Address: Optional("fe80::1ebc:680b:100:0")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: en0
Address: Optional("fe80::1ebc:680b:100:0")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: en0
Address: Optional("2001:984:3427:1:1ebc:680b:100::")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: en0
Address: Optional("2001:984:3427:1:1ebc:680b:100::")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: en0
Address: Optional("::2bc:680b:100:0")
Family: NetUtils.Interface.Family.ipv4
Supports multicast: true
Name: awdl0
Address: Optional("fe80::1ebc:680b:100:0")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: utun0
Address: Optional("fe80::1ebc:680b:100:0")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Name: utun0
Address: Optional("fde6:4b33:67e4:9d5e:1ebc:680b:100::")
Family: NetUtils.Interface.Family.ipv6
Supports multicast: true
Any help is much appreciated!