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

Julien Barbot klyr@REDACTED
Mon Oct 4 19:11:23 CEST 2010


On 10/04/2010 06:25 PM, Michael Santos wrote:
> 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<klyr@REDACTED>  wrote:
>>>> 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.
>>>>
>>> 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

Sorry for this, I though it was running on Windows Vista but did not 
test it on previous versions.

>> 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.

So be it :) This is more simple than my solution. I do not have time to 
check it now, nor time to check it on a Windows version less than 
Windows Vista.

> 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