问题
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.
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?
Thanks.
回答1:
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.
来源:https://stackoverflow.com/questions/1243093/get-device-ip-with-bonjour