NSMachBootstrapServer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSPortNameServer.h
Related sample code

Overview

This port name server takes and returns instances of NSMachPort.

Port removal functionality is not supported in NSMachBootstrapServer; if you want to cancel a service, you have to destroy the port (invalidate the NSMachPort given to registerPort:name:).

Tasks

Getting the Server Object

Looking Up Ports

Registering Ports

Class Methods

sharedInstance

Returns the shared instance of the bootstrap server.

+ (id)sharedInstance
Return Value

The shared instance of NSMachBootstrapServer with which you register and look up NSMachPort objects.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSPortNameServer.h

Instance Methods

portForName:

Looks up and returns the port registered under the specified name on the local host.

- (NSPort *)portForName:(NSString *)portName
Parameters
portName

The name of the desired port.

Return Value

The port associated with portName on the local host. Returns nil if no such port exists.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSPortNameServer.h

portForName:host:

Looks up and returns the port registered under the specified name.

- (NSPort *)portForName:(NSString *)portName host:(NSString *)hostName
Parameters
portName

The name of the desired port.

hostName

Because NSMachBootstrapServer is a local-only server; hostName must be the empty string or nil.

Return Value

The port associated with portName on the local host. Returns nil if no such port exists.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSPortNameServer.h

registerPort:name:

Registers a port with a specified name.

- (BOOL)registerPort:(NSPort *)port name:(NSString *)portName
Parameters
port

The port object to register with the bootstrap server.

portName

The name to associate with port.

Return Value

YES if the registration succeeded, NO otherwise.

Special Considerations

Once registered, a port cannot be unregistered; instead, you need to invalidate the port.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSPortNameServer.h

servicePortWithName:

Looks up and returns the port for the vended service that is registered under the specified name.

- (NSPort *)servicePortWithName:(NSString *)name
Parameters
name

The name of the vended service.

Return Value

The port associated with name. Returns nil if no such port exists.

Availability
  • Available in OS X v10.5 and later.
Related Sample Code
Declared In
NSPortNameServer.h