gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:05:14 25 4
gpt4 key购买 nike

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

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

但您必须定义 SERVICE_TYPE,例如:

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

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

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

提前谢谢你。

最佳答案

我正在使用

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

它为我提供了 LAN 上所有可用服务的列表:

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

关于android - 使用 android NSD 发现网络中的所有服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30421533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com