[Twisted-Python] Cannot perform IPv6 Link-Local Multicast on Twisted
I am trying to use the .joinGroup() by passing the IPv6 link-local multicast add. ff02::1 but get DNS lookup failure error. I am trying to use the UDP multicast example on the twistedmatrix.com website and simply replacing the IPv4 multicast address with the IPv6 one. I have also posted a query on StackOverflow: http://stackoverflow.com/questions/36034258/ipv6-link-local-multicast-on-twi... I am newbie on Twisted and some suggestions would be appreciated. Thanks a lot Shan Shantanoo Desai (Shan Desai)
On Mar 16, 2016, at 6:41 AM, Shantanoo Desai <itsmeshantanu@hotmail.com> wrote:
I am trying to use the .joinGroup() by passing the IPv6 link-local multicast add. ff02::1 but get DNS lookup failure error.
I am trying to use the UDP multicast example on the twistedmatrix.com <http://twistedmatrix.com/> website and simply replacing the IPv4 multicast address with the IPv6 one.
I have also posted a query on StackOverflow: http://stackoverflow.com/questions/36034258/ipv6-link-local-multicast-on-twi... <http://stackoverflow.com/questions/36034258/ipv6-link-local-multicast-on-twi...>
I am newbie on Twisted and some suggestions would be appreciated.
I haven't had time to fully investigate, but unfortunately, this is probably a hard-coded limitation of Twisted, currently. The right thing for you to do would be to contribute a patch to Twisted that fixes this; please file a ticket for that if there isn't one already. But, in the interests both of telling you how you might write that patch, and also how to work around it right now, let me explain: 'listenMulticast' constructs a MulticastPort which has an addressFamily of AF_INET (i.e.: IPv4). In order to join an IPv6 group, you would need one that supports IPv6. The right way to do this within Twisted is to set the address family the way that twisted.internet.tcp._BaseTCPClient does; check if the input 'interface' is a literal ipv4 or ipv6 address and set the self.addressFamily accordingly. However, assuming you don't care about Windows, as a quick workaround (this is NOT a good long-term solution; at some point in the distant future, `twisted.internet.udp´ will hopefully disappear as an importable module, since you should always be doing this sort of thing via the reactor), you could do something like this: from socket import AF_INET6 from twisted.internet.udp import MulticastPort class MyMulticastPort(MulticastPort, object): addressFamily = AF_INET6 def listenMulticast(reactor, port, protocol, interface='', maxPacketSize=8192, listenMultiple=False): p = MyMulticastPort(port, protocol, interface, maxPacketSize, reactor, listenMultiple) p.startListening() return p Note that this is totally untested, which is why I'm answering here and not Stack Overflow :-). Let me know if it works! -glyph
participants (2)
-
Glyph
-
Shantanoo Desai