在 Android 中定位主机侦听器的最简单方法是什么?
我有一个应用程序需要在本地网络上查找特定主机/端口。我想找到像 bonjour 这样的东西,它位于网络上的计算机上,通知任何关心他们在哪里的人,以及一个 Android 配套库,我可以用它来定位这个呼叫者。 这样的事情存在吗?我似乎找不到它,但也许我只是没有有效地措辞我的搜索词。
TIA
I have an app that needs to find a specific host/port on a local network. I would like to find something like bonjour that sits on a computer on a network and notifies whoever cares where they are, and a companion library for Android that I can use to locate this caller.
Does something like this exist? I can't seem to find it, but perhaps I'm just not wording my search term usefully.
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在构建一个通过 Bonjour 服务发现硬件 IP/端口的应用程序。为此,Android 应用程序使用 jmDNS,它通过多播支持 Zero-Conf/Bonjour 规范。如果您的服务端已经实现了Bonjour服务,您可以使用该库来定位它。如果您尚未注册服务,以下关于 jmDNS 的快速教程应该可以让你继续前进。
它的工作原理是发送多播消息,并且尝试发现服务的类正在实现 ServiceListener 监听 Service 的添加/删除/解析。解决服务后,您可以从 ServiceInfo 获取="http://jmdns.sourceforge.net/apidocs/javax/jmdns/ServiceEvent.html#getInfo%28%29" rel="nofollow">ServiceEvent.getInfo 其中包含主机和端口
I am building an app that discover a hardware IP/Port via Bonjour service. For that purpose, the Android app uses jmDNS which support Zero-Conf/Bonjour specs via Multicast. If your service end is already implementing Bonjour service, you could use the library to locate it. If you haven't gotten your Service registered, the following Quick Tutorial on jmDNS should be able to get you going.
It works by sending a Multicast message and the class that is trying to discover the service is implementing ServiceListener that listens when the Service is added/removed/resolved. Once the service is resolved you can get the ServiceInfo from the ServiceEvent.getInfo which contains both host and port