擅长:python、mysql、java
<p>你有几个选择。</p>
<p>您可以在整个网络地址空间中运行端口扫描,但这非常浪费而且不友好。我不推荐。</p>
<p>更好的方法是使用诸如<a href="http://www.dns-sd.org/" rel="nofollow noreferrer">DNS-SD</a>/<a href="http://en.wikipedia.org/wiki/Zeroconf" rel="nofollow noreferrer">Zeroconf</a>(又称<a href="http://en.wikipedia.org/wiki/Bonjour_%28software%29" rel="nofollow noreferrer">Bonjour</a>)的服务发现协议查询设备。大多数Linux和Mac系统都会响应,许多网络打印机和其他网络设备也会响应。Windows系统不附带DNS-SD代理,但可以安装一个。</p>
<p>DNS-SD的纯python实现是<a href="https://launchpad.net/pyzeroconf" rel="nofollow noreferrer">available here</a>。我在Linux、MacOS和Windows上使用过它。</p>
<p>如果你喜欢微软的方法,你可以尝试一下<a href="http://en.wikipedia.org/wiki/Universal_Plug_and_Play" rel="nofollow noreferrer">UPnP</a>的发现特性,尽管我不能保证它有多好的工作或者有多少系统会响应。</p>