obrien.andrew / gmail.com wrote:

> Thanks for the quick reply, Paul.
> 
> I'm not sure I follow: my /etc/hosts had "127.0.0.1" and "localhost"
> already specified.  I had to add a line for "127.0.0.1" and
> "monkeydrome", which is the name I had in the Sharing Preference Pane
> (and what Socket::gethostname returns).

I don't recommend this. In many cases, assigning 127.0.0.1 to the system
hostname as well as localhost will cause complete confusion in your local
network.

In any case, if you put a reasonable entry in /etc/hosts, like this:

192.168.0.1     monkeydrome.com monkeydrome

You should get the expected outcome.

> 
> My confusion was that I had given the computer a name and I would have
> thought that that name would resolve to something,

It cannot resolve to an IP unless an IP has been assigned, either by DHCP,
by way of /etc/hosts, or some third approach. Having a defined host name
won't produce an address resolution if there is no assigned address.

I want to emphasize that "localhost" is the name of the loopback
pseudo-adaptor, it normally has the address 127.0.0.1, and you don't want
to assign this same address to the system. If you do, the system won't be
visible to your network.

A minimal /etc/hosts might look like this:

127.0.0.1     localhost.localdomain   localhost
192.168.0.1   monkeydrome.com         monkeydrome

There may be some differences on OS X, the above is typical in Linux. Also,
obviously, the address you assign to the local system might not be such a
generic choice as 192.168.0.1, although that is a reasonable choice if you
don't have a special reason to use another.

-- 
Paul Lutus
http://www.arachnoid.com