Python 2.7 在所有网络上搜索设备

Python 2.7 在所有网络上搜索设备,python-2.7,udp,twisted,upnp,ssdp,Python 2.7,Udp,Twisted,Upnp,Ssdp,我想实现一个代码,通过它我可以列出连接到网络上的符合upnp的媒体渲染器设备。我在谷歌上搜索了一下,发现了下面的代码 在我的机器上连接两个网络(以太网和wifi)时,它只列出一个网络的设备 code from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor import re class MulticastPingPong(DatagramProtocol):

我想实现一个代码,通过它我可以列出连接到网络上的符合upnp的媒体渲染器设备。我在谷歌上搜索了一下,发现了下面的代码

在我的机器上连接两个网络(以太网和wifi)时,它只列出一个网络的设备

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()
如何搜索多个网络的设备