Beginning Objective-C by James Dovey & Ash Furrow

Beginning Objective-C by James Dovey & Ash Furrow

Author:James Dovey & Ash Furrow
Language: eng
Format: epub, pdf
ISBN: 9781430243687
Publisher: Apress


Network Service Location

Back in the days of yore (a.k.a. the 1990s) Apple computers used a suite of protocols called AppleTalk to communicate on a local network (or even further!). While the main networking protocol hasn’t aged well and is very rarely used today, the suite had some very useful features, not the least of which was the Name Binding Protocol (NBP), which had the capability to advertise the availability of services across the network. In the world of the Internet Protocol and Ethernet, however, nothing similar existed. To connect to a web server, you needed to know its address and you would connect to port 80. If there was another web server running on a different port, someone would have to tell you about it explicitly so that you might connect. The Domain Name System (DNS) offers a means of obtaining an IP address based on a name such as www.apple.com . This normally requires a dedicated server and manual configuration, however, which makes it a poor solution for non-technical users.

In 2002, Apple engineer Stuart Cheshire designed and published a new standard through the Internet Engineering Task Force entitled DNS Service Discovery. This standard described various updates to the DNS system and protocol, adding support for the resolution of information on individual services on a system to their individual port numbers. It also added a protocol through which a query to a DNS service could remain active, receiving updates whenever changes occurred without needing to reconnect and poll the server continually. This was then married to the multicast DNS (mDNS) system built into OS X 10.2 to allow all hosts on a local area network to provide information on any services available on that host. The result was named Rendezvous, although its name was sadly changed to the less appropriate Bonjour6 two years and one trademark lawsuit later.

The Bonjour service is available in both OS X and iOS, implemented at a very low level. Luckily for you, it has a series of higher-level APIs available right up to the Cocoa layer, allowing you to not only find services on the local network but also advertise your own in only a few easy steps.

Service Resolution

You can search the network for services of a given type using an instance of the NSNetServiceBrowser class. The service browser object operates asynchronously and sends messages to a delegate object on a given run loop as it encounters various events. A browser can be used to search for available domains either for browsing or registering new services (a domain may be browsable but not support dynamic addition of new items), or it can search a domain for services. The browser’s delegate can implement a number of different methods to receive updates during the search process, which are outlined in Table 6-2.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.