| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in Mac OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSPortNameServer.h |
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.
You get an NSPortNameServer object by using the systemDefaultPortNameServer class method—never allocate and initialize an instance directly. With the default server object you can register an NSPort object under a given name, making it available on the network, and also unregister it so that it can’t be looked up (although other applications that have already looked up the NSPort object can still use it until it becomes invalid). See the NSPort class specification for more information.
Returns the single instance of NSPortNameServer for the application.
+ (NSPortNameServer *)systemDefaultPortNameServer
The single instance of NSPortNameServer for the application.
NSPortNameServer.hLooks up and returns the port registered under the specified name on the local host.
- (NSPort *)portForName:(NSString *)portName
The name of the desired port.
The port associated with portName on the local host. Returns nil if no such port exists.
Invokes portForName:host: with nil as the host name.
NSPortNameServer.hLooks up and returns the port registered under the specified name on a specified host.
- (NSPort *)portForName:(NSString *)portName host:(NSString *)hostName
The name of the desired port.
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.
The port associated with portName on the host hostName. Returns nil if no such port exists.
NSPortNameServer.h
Makes a given port available on the network under a specified name.
- (BOOL)registerPort:(NSPort *)aPort name:(NSString *)portName
The port to make available.
The name for the port.
YES if successful, NO otherwise (for example, if another NSPort object has already been registered under portName).
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.
NSPortNameServer.hUnregisters the port for a given name on the local host.
- (BOOL)removePortForName:(NSString *)portName
The name of the port to unregister.
YES if successful, otherwise NO.
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.
NSPortNameServer.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-01-29)