Chapter 8. Using the Java APIs
Starting in Mac OS X 10.3.9, new APIs enable Java software to advertise and discover services on the network using Zeroconf’s DNS Service Discovery. The same Java DNS-SD APIs are also available in Bonjour for Windows, Bonjour for Linux, Solaris, *BSD, etc., enabling Java software to make use of Zeroconf’s DNS Service Discovery across a wide range of platforms, not just on Mac OS X. In this chapter, you will take a quick look through the APIs, see short examples of how to register, browse for, add TXT records to, and resolve services, and finally see a complete example of using Java DNS-SD in a tic-tac-toe game.
Understanding the APIs
The com.apple.dnssd package exposes an abstract
factory class, DNSSD, used to create the various
types of DNSSDService objects, two classes used to
manipulate DNS records, a collection of interfaces that are implemented as appropriate
by client code to receive callback messages, and an exception:
Factory Class :
DNSSD
References to ongoing asynchronous operations :
DNSSDServiceDNSSDRegistration
DNS Record Classes:
DNSRecordTXTRecord
Callback Interface Classes , implemented by client:
BaseListenerRegisterListenerBrowseListenerResolveListenerDomainListenerQueryListener
DNSSD Error Exception:
DNSSDException
The pattern for using the APIs will most often consist of calling a
static method from the DNSSD factory class, passing in an instance of a class that implements the appropriate interface to receive callback ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access