[erlang-questions] reliably figure out hostname

Tim Watson <>
Fri Aug 3 01:02:01 CEST 2012

On 2 August 2012 23:28, Geoff Cant <> wrote:
> You could just cheat and make the hostname part of your longname either a) the hostname of the system you're trying to connect to, or b) a local ip address converted to an atom (i.e. '') if you make a hidden connection. It's a little non-kosher, but generally works.

This has crossed my mind! The gen_udp based approach doesn't fly, as
you noticed too, for the same reasons that calling 'hostname' via the
OS doesn't always tell you whether or not `-name foo` will work
without the FQDN.

I'm not actually sure how using an IP address plays with short versus
longnames - I'll experiment with that, thanks.

> Erlang distribution is about the only thing I use on a regular basis that expects DNS to be configured such that:
> 1. Any machine can construct its own hostname.
> 2. These hostnames can be passed off to any third party, and they can subsequently use that hostname to connect back to the original host.
> In most places I've worked, 1 is dicey but fixable, and 2 prompts weird looks from the ops/network team.

Yep. The main thing I'm using the test framework for completely
depends on distributed Erlang though, so there's little point in
skirting the issue. I'll probably simply force users to enter the full
hostname for longnames and provide a way to override the resolution of
localhost per machine using a config file, so developers don't have to
keep editing the test setup when they check out from source control.

For those using shortnames, none of this seems to really matter.

More information about the erlang-questions mailing list