问题描述
我使用 Java 6 update 14 进行开发和 NetBeans 6.7.我正在创建一个示例客户端来使用 Bonjour 检测特定类型的服务.
I am using Java 6 update 14 for development and NetBeans 6.7. I am creating a sample client to detect particular type of service using Bonjour.
我面临着一个挑战,我想获取设备的 IP 地址.但是 ResolveListener.serviceResolved(...) 函数,只提供 Hostname 和 Port.FullName 也不包含设备的 IP 信息.是否可以使用 Bonjour SDK 获取设备的 IP 地址?如果是,如何?
I face a certain challenge where I want to get the IP address of the device. But the ResolveListener.serviceResolved(...) function, provides only Hostname and Port. The FullName also does not contain IP information of the device. Is it possible to obtain the IP address of the device using Bonjour SDK? If yes, how?
谢谢.
推荐答案
使用标准 Java InetAddress 类将主机名解析为 IP 地址.ZeroConf(Bonjour 是 Apple 的实现)通过主机名相当合理地抽象了服务主机.
Use the standard Java InetAddress class to resolve the hostname to an IP address. ZeroConf (Bonjour being Apple's implementation) quite reasonably abstracts service-hosts by hostname.
这篇关于使用 Bonjour 获取设备 IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!