android resolve .local (mDNS)(android 解析 .local (mDNS))
问题描述
我正在寻找使用 Android 4.0.4(无 NSD,由于 API 级别 15)解析 .local 主机名的解决方案.在我没有任何服务要发现的设备上,只有主机名.您能否提供一个如何解决的示例?我集成了jmDNS,但不知道如何用于主机名解析.
I'm looking for a solution to resolve .local host names with Android 4.0.4 (no NSD, due to API level 15). On the device I don't have any service to discover, just the hostname. Could you please provide an example how to resolve? I integrated the jmDNS, but don't know how to use for host name resolving.
win-cmd:
ping kcmeasurement.local
Pinging kcmeasurement.local [10.202.0.29] with 32 bytes of data:
Reply from 10.202.0.29: bytes=32 time<1ms TTL=64
...
谢谢,
丹尼尔
推荐答案
我的要求和你的问题差不多,除了需要使用jmDNS,所以我用NSD解决了.我意识到这并不能完全解决您的问题,但认为看看我如何解决它可能对您自己和其他人仍然有所帮助.
I had almost the same requirements as your question, apart from the requirement to use jmDNS, so I solved it with NSD. I realize this doesn't address your question exactly, but thought it might still be somewhat helpful for yourself and others to see how I solved it.
我设置了一个 NSD 发现侦听器和一个 NSD 解析侦听器,并在发现侦听器代码中为目标主机名添加了一个过滤器(例如kcmeasurement",或者在我的情况下为garagedoor").
I setup an NSD discovery listener and an NSD resolve listener, and within the discovery listener code, added a filter for the target host name (e.g. "kcmeasurement", or in my case, "garagedoor").
这里有一篇博文详细解释了如何做到这一点.参考步骤3-4,处理所需的Android App代码.
There is a blog post here which explains in detail how to do that. Refer to steps 3-4, which are dealing with the Android App code required.
http://www.dodgycoder.net/2015/02/设置-bonjourzeroconfmdnsnsd.html
对于您的情况,我想您将不得不执行相同的过程,但只使用 jmDNS 库而不是 NSD.
For your case, I would imagine you would have to do the equivalent process but just using the jmDNS library instead of NSD.
这篇关于android 解析 .local (mDNS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:android 解析 .local (mDNS)
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01