[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSHost name

From: Riccardo Mottola
Subject: Re: NSHost name
Date: Mon, 19 May 2014 10:16:28 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26


Richard Frith-Macdonald wrote:
If you look at the documentation (either the GNUstep documentation or the Apple 
documentation) you will see that your expectation is misguided ... the -name 
method returns*a*  name of the host, not necessarily any particular one.
Ok! fine, I expected some smartness which is not guaranteed, the method can just return any of the names.

If you have code which prefers particular names, you should use the -names 
method to get all the names for the host, and then use some heuristic to pick 
the one you prefer to use.
In GWorkspace, which was affected by this, I enhanced the logic by getting all names and using some heuristic prior to applying the already existing "cleaning" of the FQDN.
I can essentially have
"localhost" + any other names, then I give preference to the others.
I may have "myHost" and then I pick that, I can have "myHost.aa.bb" for a FQDN, in that case I try to pick myHost if available, else, if only the FQDN exist, then the existing "cleaning" logic that gets the first name before the "." remains in place.

Tries to work fine here and fixes my OpenBSD laptop too!
All that being said ... I suspect the behavior you are looking for is that of 
the -localizedName method Apple added in OSX 10.6
I've just hacked in a quick implementation (untested) in svn trunk that you 
could try.
In my other small tool where I was experiencing this and which led me to this analysis, I used localizedName and it appears to work for me! it returns "myHost" instead of localhost and that's enough for me. If it were a FQDN, it would be fine too. Essentially, give me just any other available name, if there is one, besides localhost.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]