Mac Developer Library

Developer

Foundation Framework Reference NSPortNameServer Class Reference

Options
Deployment Target:

On This Page
Language:

NSPortNameServer

NSPortNameServer provides an object-oriented interface to the port registration service used by the distributed objects system. NSConnection objects use it to contact each other and to distribute objects over the network; you should rarely need to interact directly with an NSPortNameServer. More...

Conforms To


Import Statement


Not Applicable @import Foundation;

Availability


Available in OS X v10.0 and later.
  • Returns the single instance of NSPortNameServer for the application.

    Declaration

    Objective-C

    + (NSPortNameServer *)systemDefaultPortNameServer

    Return Value

    The single instance of NSPortNameServer for the application.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Objective-C

    - (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.

    Discussion

    Invokes portForName:host: with nil as the host name.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Objective-C

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

    Parameters

    portName

    The name of the desired port.

    hostName

    The name of the host. hostName is an Internet domain name (for example, “sales.anycorp.com”). If hostName is nil or empty, the local host is checked.

    Return Value

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

    Import Statement

    Availability

    Available in OS X v10.0 and later.

  • Makes a given port available on the network under a specified name.

    Declaration

    Objective-C

    - (BOOL)registerPort:(NSPort *)aPort name:(NSString *)portName

    Parameters

    aPort

    The port to make available.

    portName

    The name for the port.

    Return Value

    YEStrue if successful, NOfalse otherwise (for example, if another NSPort object has already been registered under portName).

    Discussion

    A port can be registered under multiple names. If it is, it must be unregistered for each name with removePortForName: to make it completely unavailable.

    Import Statement

    Availability

    Available in OS X v10.2 and later.

  • Unregisters the port for a given name on the local host.

    Declaration

    Objective-C

    - (BOOL)removePortForName:(NSString *)portName

    Parameters

    portName

    The name of the port to unregister.

    Return Value

    YEStrue if successful, otherwise NOfalse.

    Discussion

    If the operation is successful, the port can no longer be looked up using the name portName. Other applications that already have a reference to the port can continue to use it until it becomes invalid.

    Import Statement

    Availability

    Available in OS X v10.0 and later.