[erlang-patches] erl_call can now use an IP address for remote node name

Michael Santos <>
Mon Oct 4 18:25:37 CEST 2010


On Mon, Oct 04, 2010 at 11:07:13AM -0400, Andrew Thompson wrote:
> On Mon, Oct 04, 2010 at 03:22:14PM +0200, Bj??rn Gustavsson wrote:
> > On Thu, Sep 23, 2010 at 1:46 PM, Julien Barbot <> wrote:
> > > Hi,
> > >
> > > erl_call was not able to connect to a remote node when the specified node
> > > with -name contained an IP address.
> > >
> > > The previous inet_addr/htonl calls were not working with ip addresses.
> > >
> > > Here is the small patch:
> > >
> > > git fetch git://github.com/klyr/otp.git erl_call_get_hostent
> > >
> > 
> > The build fails on Windows like this:
> > 
> > cc.sh -MD -O2 -Wall -I. -I../include -Iconnect -Iencode -Idecode
> > -Imisc -Iepmd -Iregistry -Iwin32   -Ilegacy -DWIN32_THREADS
> > -D_WIN32_WINNT=0x0500 -DWINVER=0x0500 -o
> > /ldisk/daily_build/otp_norel_pu_win32_r14b01.2010-10-03_23/otp_src_R14B01/lib/erl_interface/bin/win32/erl_call.exe
> > prog/erl_call.c prog/erl_start.c \
> > 
> > -L/ldisk/daily_build/otp_norel_pu_win32_r14b01.2010-10-03_23/otp_src_R14B01/lib/erl_interface/obj/win32
> > -lei_md   -lsocket
> > erl_call.o : error LNK2019: unresolved external symbol _inet_pton
> > referenced in function _get_hostent
> > C:/cygwin/ldisk/daily_build/otp_norel_pu_win32_r14b01.2010-10-03_23/otp_src_R14B01/lib/erl_interface/bin/win32/erl_call.exe
> > : fatal error LNK1120: 1 unresolved externals
> > 
> > 
> > I will drop the branch from pu.
> > 
> 
> This could probably be resolved with a simple ifdef for windows support.
> Windows Vista has inetPton, but on earlier versions you probably want to
> use WSAStringToAddress or something (which is available since win2k).

Here is a minimal patch that fixes Julien's problem. The return value
of inet_addr() is always big endian.

diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c
index 448de9a..a18d29a 100644
--- a/lib/erl_interface/src/prog/erl_call.c
+++ b/lib/erl_interface/src/prog/erl_call.c
@@ -614,5 +614,4 @@ static struct hostent* get_hostent(char *host)
     struct in_addr ip_addr;
     int b1, b2, b3, b4;
-    long addr;
       
     /* FIXME: Use inet_aton() (or inet_pton() and get v6 for free). */
@@ -620,6 +619,5 @@ static struct hostent* get_hostent(char *host)
 	return NULL;
     }
-    addr = inet_addr(host);
-    ip_addr.s_addr = htonl(addr);
+    ip_addr.s_addr = inet_addr(host);
       
     return ei_gethostbyaddr((char *)&ip_addr,sizeof(struct in_addr), AF_INET);


More information about the erlang-patches mailing list