2015-05-24 45 views
5

我正尝试利用找到网络中的所有服务:发现网络中的所有服务的Android NSD

mNsdManager.discoverServices(
      SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener); 

,但你必须定义SERVICE_TYPE例如:

public static final String SERVICE_TYPE = "_http._tcp."; 

所以将使用tcp发现所有http服务,但它不会同时查找https服务或任何其他类型的服务

如何设置所有这些以便使用tcp查找任何服务?

预先感谢您。

+0

对此有何更新? – user3316561

回答

1

我使用

private static final String SERVICE_TYPE = "_services._dns-sd._udp"; 

这给了我的所有可用服务的局域网上的列表:

D/MHC-NSD: Service discovery found: name: _workstation, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _UnoWiFi, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _udisks-ssh, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _airplay, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _raop, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _xbmc-events, type: _udp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _xbmc-jsonrpc, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _xbmc-jsonrpc-h, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _http, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _sftp-ssh, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _ssh, type: _tcp.local., host: null, port: 0 
D/MHC-NSD: Service discovery found: name: _arduino, type: _tcp.local., host: null, port: 0