EcHost documentation

Authors

Richard Frith-Macdonald (rfm@gnu.org)

Copyright: (C) 2012 Free Software Foundation, Inc.

Software documentation for the NSHost(EcHost) category

NSHost(EcHost)

Declared in:
EcHost.h

This category provides additional methods to standardise host names so that software can consistently refer to a host by a single well known name.
This mechanism, as well as ensuring naming consistency, can be used to work with logical names for hosts when the actual naming of the hosts (ie in the domain name system) is not under your control.

This operates by managing a map from the various names and addresses a host may be known by, to a single well known name. This host name may, but need not, be a public domain name.

The well known name methods are thread-safe, and on initial use the NSUserDefaults system is queried to set up two well known names automatically:
The value of EcCurrentHost specifies the well known name for the current host (the machine on which the software is running).
The value of EcControlHost specifies the well known name for the control host (the machine on which control functions for your software are centralised). If this is specified without EcControlDomain, it is used as both the well known name and the domain name.
The value of EcControlDomain specifies the fully qualified domain name (ie the name provided by the operating system) of the control host. If it is specified without EcControlHost, then it is used as the well known name for the control host.
NB. the defaults system is accessed via EcUserDefaults, so if a defaults prefix other than Ec has been set, these keys will use that alternative prefix.

Method summary

controlWellKnownName 

+ (NSString*) controlWellKnownName;
Returns the well known name of the 'control' host as obtained from the NSUserDefaults system.
If EcControlHost is defined, the well known name is the string specified by EcControlHost.
If EcControlHost is undefined but EcHostControlDomain is defined, the well known name is the value of EcHostControlDomain.
If neither is defined, this method returns nil.

hostWithWellKnownName: 

+ (NSHost*) hostWithWellKnownName: (NSString*)aName;
Returns a host previously established as having the well known name, or nil if no such association exists.

setWellKnownNames: 

+ (void) setWellKnownNames: (NSDictionary*)map;
Establishes mappings from a variety of host names (the dictionary keys) to well known names (the dictionary values).
The keys and values may be (and often are) identical in the case where the well known name for a host is the same as one of its normal names (eg its fully qualified domain name).
It is possible to set a well known name for a host which does not yet exist... in which case the mapping will be established and will take effect later, when the host is set up.

setWellKnownName: 

- (void) setWellKnownName: (NSString*)aName;
Sets the well known name for the receiver.
This replaces any previous well known name for the receiver and, if the name is already in use, removes any associations of that well known name with other hosts.

wellKnownName 

- (NSString*) wellKnownName;
Returns the well known name for the receiver (or any name of the receiver if no well known name has been set for it).