Turning to get multicast, this is the following code example. I am currently listening to many groups with the same customer and I want to know which group came from a specific datagram packet. I would think that this can be obtained from the address parameter of the datagram; However, it only gives me local ip and ported tubal which is bound to a group, but the group is not aware of it.
Question: How can I print the multicast address from where a datagram is generated from within the twisted protocol / API? Imported Datagram Protocol from Twisted.internet.protocol Import. Importer Reactor Class Multicastpipping Client (Datagram Protocol): Def Start Protocol (Self): Join the # Multicast Address, so we can get answers: self.transport.joinGroup ("228.0.0.5") self.transport.joinGroup ("22 9.0.2.11 ") send to self.transport.joinGroup (" 221.3.3.3 ") # 228.0.0.5:8005 - All listeners (including us) will receive this message at Multicast Address #. Self. Transport (written: 'Client: ping', ("228.0.0.5", 8005)) DIF datagram received (self, datagram, address): print "Datagram% s received from% s"% (rip (datagram), rip (Address)) Reactor.LitanMultiCast (8005, Multicast Ping Client (), SunnemaltyPlat = True) Reactor.Ran () Unfortunately, the mistake API is twisted (via Python's standard library) does not provide this information Land. I would recommend a separate datagram prototype for each multicast group, and each has to listen to different ports. Although no UDP can send the datagram to the port directly, and you will not be able to separate it from multicast. I have an ambiguous memory that indicates that the recvmsg () API provides the necessary information, although I lack the time to confirm it. Twisted 12.1 is the beginning of a recvmsg (wrapper), so it can be a possible way to combine this combat (or your code) with a little more work.
Comments
Post a Comment