I want to implement a code through which i can list-up upnp compliant media renderer devices connected on network. I googled for this and found following code on twisted website
When 2 networks(ethernet and wifi) are connected on my machine, it lists up devices of only one network.
code
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
import re
class MulticastPingPong(DatagramProtocol):
XMLNS = "{urn:schemas-upnp-org:device-1-0}"
def startProtocol(self):
# Join the multicast address, so we can receive replies:
self.transport.joinGroup("239.255.255.250")
def datagramReceived(self, datagram, address):
if(re.search("USN:.*MediaRenderer", datagram, flags=re.IGNORECASE)):
# code to print friendly name
reactor.listenMulticast(1900, MulticastPingPong(), listenMultiple=True)
reactor.run()
How to search devices of multiple networks ?