发现使用Android NSD的网络中的所有服务

7
我正在尝试使用以下方法查找网络中的所有服务:

```

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

但是您必须定义SERVICE_TYPE,例如:
public static final String SERVICE_TYPE = "_http._tcp.";

因此,它将使用TCP发现所有HTTP服务,但同时不会找到HTTPS服务或任何其他类型的服务。

我该如何设置才能查找使用TCP的任何服务?

谢谢您提前。

1个回答

5

我正在使用

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接