Introduction

The Network Services Location Manager provides a protocol-independent way for applications to discover available network services with minimal network traffic. This document describes the programming interface for the Network Services Location Manager for Mac OS X 10.2.

What’s New in the Network Services Location Manager

The following changes have been made in the Network Services Location Manager for Mac OS X 10.2:

Overview of the Network Services Location Manager

The Network Services Location Manager provides

A wide variety of applications become easier to use when they call the Network Services Location Manager. For example,

The Network Services Location Manager acts as an intermediary between the providers of network services and applications that want information about such services. It also registers network services that make registration requests.

You can use the Network Services Location Manager to

This version the Network Services Location Manager runs only on Power PC computers on which Mac OS X is installed. Before your application calls the Network Services Location Manager, it should verify that Mac OS X is running.

If your Mac OS X application only calls NSLStandardGetURL, you need only link to the Carbon library. To build a Mac OS X application that calls Network Services Location Manager functions other than NSLStandardGetURL, link to /System/Library/Frameworks/CoreServices.framework.

To build an application that calls the Network Services Location Manager and that runs on both Mac OS 9 and Mac OS X, link to the Carbon library only.

Locating Services

The Network Services Location Manager uses Open Directory to locate network services, as shown in Figure 1-1.

Figure 1-1  Search for a network service

Applications that search for services can focus the search by specifying two values:

  • a services list, a Network Services Location Manager data type that specifies one or more services that are to be searched for

  • a neighborhood, a Network Services Location Manager data type that defines the boundaries for searches. Neighborhoods are established by administrators when they set up their networks for NBP and SLP. When an application calls the Network Services Location Manager’s NSLStandardGetURL function to display a dialog box that allows users to look for services, users can supplement the neighborhoods in which searches are conducted by adding neighborhoods to a list of favorite neighborhoods. Applications that don’t call NSLStandardGetURL call NSLStartNeighborhoodLookup to get a list of available neighborhoods.

A neighborhood is abstract information about where services may reside. In Mac OS X 10.2 and later, a neighborhood consists of one or more Open Directory “nodes.” A node can be an SLP scope, a DNS domain, an AppleTalk zone, a Windows neighborhood, or a directory published by NetInfo, LDAP, or a third-party Open Directory plug-in. The Network Services Location Manager works with Open Directory to query these nodes for information about services. The Network Services Location Manager uses nodes to abstract a consistent view of the network that can be browsed in a way that is independent of the caller.

The following steps outline the conduct of a search for a service:

  1. The application creates a search request and calls the Network Services Location Manager’s NSLStartServicesLookup function.

  2. The Network Services Location Manager receives the request and passes it to Open Directory, which passes the request to the appropriate Open Directory plug-in.

  3. The Open Directory plug-in that receives the request starts to look for the requested services.

  4. Providers of the requested services send their responses to the Open Directory plug-in, which makes the responses available to Open Directory.

  5. Open Directory passes the responses to the Network Services Location Manager.

  6. The Network Services Location Manager passes the responses to the application that called NSLStartServiceLookup.

Registering Services

Applications that provide services register themselves with the Network Services Location Manager as shown in Figure 1-2 so that they can be found by applications that use their services.

Figure 1-2  Flow of a service registration

The following steps outline the flow of a service registration:

  1. The application creates a value that specifies the URL to register. It may call the Network Services Location Manager utility function, NSLHexEncodeText, to encode portions of the URL that may contain characters (such as spaces) that are not allowed in URLs. Then the application calls the Network Services Location Manager’s NSLStandardRegisterURL function to register the URL. In most cases, applications pass a null value as the neighborhood. Passing a null value causes the Network Services Location Manager to register the service in the appropriate local neighborhood.

  2. The Network Services Location Manager receives the request and passes it to the Open Directory SLP plug-in.

  3. If the Open Directory SLP plug-in can register the URL, it returns a value indicating that the service was registered successfully, which the Network Services Location Manager passes to the calling application.