android 解析 .local (mDNS)

android resolve .local (mDNS)(android 解析 .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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)