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

查看:573
本文介绍了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
...

谢谢

丹尼尔(Daniel)

Daniel

推荐答案

除了使用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/setting-up-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天全站免登陆