PATH  Documentation > Mac OS X > Foundation Reference: Objective-C



Table of Contents

NSPortNameServer


Inherits from:
NSObject
Conforms to:
NSObject
(NSObject)
Declared in:
Foundation/NSPortNameServer.h




Class Description


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 by using the systemDefaultPortNameServer class method-never allocate and initialize an instance directly. With the default server object you can register an NSPort 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 can still use it until it becomes invalid). See the NSPort class specification for more information.




Method Types


Getting the server object
+ systemDefaultPortNameServer
Looking ports up
- portForName:
- portForName:onHost:
Registering ports
- registerPort:forName:
- removePortForName:


Class Methods



systemDefaultPortNameServer

+ (NSPortNameServer *)systemDefaultPortNameServer

Returns the single instance of NSPortNameServer for the application.


Instance Methods



portForName:

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

Looks up and returns the NSPort registered under portName on the local host. Invokes portForName:onHost: with nil as the host name. Returns nil if no such NSPort exists.

See Also: - portForName:onHost:



portForName:onHost:

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

Looks up and returns the NSPort registered under portName on the host named hostName. hostName is an Internet domain name (for example, "sales.anycorp.com"). Returns nil if no such NSPort exists.

If hostName is nil or empty then only the local host is checked for portName. If hostName is "*" then all hosts on the local subnet are queried for the requested NSPort-where there are duplicates an arbitrary host's NSPort is returned. That host is then used for every subsequent request by the local host.



registerPort:forName:

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

Makes aPort available on the network under portName and the local host's name (or names). Returns YES if successful, NO otherwise (for example, if another NSPort has already been registered under portName). An NSPort can be registered under multiple names. If it is, it must be unregistered for each name with removePortForName: to make it completely unavailable.

removePortForName:

- (void)removePortForName:(NSString *)portName

Unregisters the NSPort for the name portName on the local host, so it can no longer be looked up by that name. Other applications that already have the NSPort can continue to use it until it becomes invalid.


Table of Contents