[squeak-dev] finding the unix localhost name

David T. Lewis lewis at mail.msen.com
Fri Mar 31 02:06:12 UTC 2023


On Wed, Mar 29, 2023 at 06:13:55PM -0700, tim Rowledge wrote:
> We've had a few discussions about this issue over the years and never really decided on anything more certain than "er, well..."
> 
> There's certainly a bigger discussion around moving to the 'new networking' setting but for this one particular query it seems to me that using the code currently in NetNameResolver class>>#localHostName that gets ignored by the #useOldNetwork option is a good option. That is, 
> 
> localHostName
> 	"Return the local name of this host."
> 	"NetNameResolver localHostName"
> 
> 	| host |
> 	host := String new: NetNameResolver primHostNameSize.
> 	NetNameResolver primHostNameResult: host.
> 	^host
> 
> returns a value that seems to be helpful, and that is retrieved via the unix function gethostname(), which is used by the hostname command. Are there any problems with the idea of using this?
>

Could someone please test this on Windows and Mac? To test it,
use Tim's change above, then find the 'Enable IPv6 and new network
support' preference in category 'General' in the preference browser.

Turn the preference on and off, and see if the localHostName method
answers something sensible in both cases.

It looks right to me on Linux but results may be different on other
platforms.

Thanks,
Dave



More information about the Squeak-dev mailing list