android 解析 .local (mDNS) [英] android resolve .local (mDNS)

查看:28
本文介绍了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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆