Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion reliably figure out hostname

Received: by 10.205.126.4 with SMTP id gu4mr4154622bkc.8.1343896723749;
        Thu, 02 Aug 2012 01:38:43 -0700 (PDT)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.130.131 with SMTP id t3ls2154069bks.9.gmail; Thu, 02 Aug
 2012 01:38:43 -0700 (PDT)
Received: by 10.205.139.2 with SMTP id iu2mr4156044bkc.7.1343896723490;
        Thu, 02 Aug 2012 01:38:43 -0700 (PDT)
Received: by 10.205.139.2 with SMTP id iu2mr4156043bkc.7.1343896723474;
        Thu, 02 Aug 2012 01:38:43 -0700 (PDT)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
        by gmr-mx.google.com with ESMTP id q3si1547886bkv.1.2012.08.02.01.38.43;
        Thu, 02 Aug 2012 01:38:43 -0700 (PDT)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org; dkim=neutral (body hash did not verify) header...@gmail.com
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
	by hades.cslab.ericsson.net (Postfix) with ESMTP id EB2DC5C0E5;
	Thu,  2 Aug 2012 10:38:36 +0200 (CEST)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
 [74.125.82.181])
 by hades.cslab.ericsson.net (Postfix) with ESMTP id 1F4CB5C001
 for <erlang-questi...@erlang.org>; Thu,  2 Aug 2012 10:38:35 +0200 (CEST)
Received: by weyt57 with SMTP id t57so6251498wey.40
 for <erlang-questi...@erlang.org>; Thu, 02 Aug 2012 01:38:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:from:date:message-id:subject:to
 :cc:content-type;
 bh=ViLu315VE4M4b+FLQ+/uvSZhXxO7wo0QAMEQkJmjXmE=;
 b=BL7KbhlpDZSRUscTzQB0XhhdsZ3qiZ7y9P8a6O3KLG3/XJNWnp9vJAMyvD0ZCisFri
 DqFxPV6U1cA1ih5pY7XKkRbQ4qFzjQBLBkN3nHo28qCVjQto3WKA3q/cemr6B2q3PGZc
 Anqgm74ALZwk5Vmj/yGT18CpnFXMei8jCdR1vPD867aGvfDYQB77527F6Z8g34POZXcn
 bEfKV+JMO4xKoAKCk2dOhAtUCRnrY7g2m6um2/qO9SiYSGlpM/qtd8NN7c6OhKXoEugV
 frgPDw6KkCbeIm3h59cvn2ZDVluc9nPcE5NSHSrl1BCk7Vsckd7BZrwquqekyg9g08vV
 aE8A==
Received: by 10.180.97.106 with SMTP id dz10mr2751991wib.21.1343896714718;
 Thu, 02 Aug 2012 01:38:34 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.223.129.195 with HTTP; Thu, 2 Aug 2012 01:38:14 -0700 (PDT)
In-Reply-To: <E284EB29-F365-4BFA-BC77-64AA7BEA3...@gmail.com>
References: <09A191ED-C75E-487C-AE5C-5F1AA6436...@gmail.com>
 <E284EB29-F365-4BFA-BC77-64AA7BEA3...@gmail.com>
From: Vlad Dumitrescu <vladd...@gmail.com>
Date: Thu, 2 Aug 2012 10:38:14 +0200
Message-ID: <CAA-EFXsc5s2Q2HNPKh1qT_Kpkk4-zaHtH=U0CuGZEMKD7SC...@mail.gmail.com>
To: Tim Watson <watson.timo...@gmail.com>
Cc: erlang-questions Questions <erlang-questi...@erlang.org>
Subject: Re: [erlang-questions] reliably figure out hostname
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org

Hi,

On Thu, Aug 2, 2012 at 10:17 AM, Tim Watson <watson.timo...@gmail.com> wrote:
> Any takers for this? I can't be the only person who's had to figure this
> out. The context is a distributed systems testing framework that needs to
> support resolving 'localhost' to a proper host name so the framework can
> become a hidden node and interact with the other erlang nodes It is testing
> against. Having to specify the real host name would make configuring the
> tool across different machines and development environments unpleasantly
> complicated so figuring out the right hostname is a boon in terms of keeping
> the configuration overhead down, but doing this for long names nodes is
> proving highly awkward.

I'm not a guru for this kind of issues, but even looking at Java's
support for this, the docs say

    String java.net.InetAddress.getCanonicalHostName()
        Gets the fully qualified domain name for this IP address. Best
effort method, meaning we may not be able to return the FQDN depending
on the underlying system configuration.

    String java.net.InetAddress.getHostName()
        Gets the host name for this IP address.
        If this InetAddress was created with a host name, this host
name will be remembered and returned; otherwise, a reverse name lookup
will be performed and the result will be returned based on the system
configured name lookup service. If a lookup of the name service is
required, call getCanonicalHostName.

So it depends on how the system is configured...

regards,
Vlad


> Can anyone suggest a good portable solution?
>
> On 31 Jul 2012, at 13:43, Tim Watson <watson.timo...@gmail.com> wrote:
>
> Is there a way to calculate the hostname reliably across platforms in
> Erlang? I have a non-distributed node that I wish to become a distributed
> node. Normally I call net_kernel:start([Name, shortnames]) and this is just
> fine. It also works with [Name, longnames] *sometimes and on some systems* -
> but other times it pukes. I've tried looking in the 'domain' or 'search'
> entries from inet:get_rc/0 but these are not always populated, even when dns
> config is clearly in place. I've also tried using 'inet_db:get_searchlist/0'
> but again, sometimes this returns [[]] but net_kernel:start([foobar,
> longnames]) doesn't work, whereas doing
> net_kernel:start([foo...@mydomain.com, longnames]) does.
>
> Am I missing something incredibly obvious here? *is* there actually a simple
> way of determining what the proper fqdn for the machine should be, without
> breaking out to the os? I had even considered doing inet:gethostbyname/1 but
> again, the search domains entry seems to be empty, so I'd assume that -name
> foobar will work whereas in fact, -name foobar@fqdn is required otherwise
> net_kernel won't start.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions