inet:ip/1

Serge Aleynikov serge@REDACTED
Wed Apr 12 23:14:42 CEST 2006


Though it doesn't quite make sense for the IPv4 case...

Moreover, the kernel/inet_parse.erl has the following comment for 
ipv4_address/1:

%% Parse IPv4 address:
%%    d1.d2.d3.d4
%%    d1.d2.d4
%%    d1.d4
%%    d4
%%
%% Return {ok, IP} | {error, einval}

I wonder what it was that authors were trying to accomplish.

Serge

Phil Snowberger wrote:
> On Wed, Apr 12, 2006 at 02:59:39PM -0400, Serge Aleynikov wrote:
> 
>>While playing with the inet:ip/1 function I noticed that it can take an 
>>argument containing less than four octets.  What's the meaning of such a 
>>strange conversion like inet:ip("1.2.3")?
>>
>>1> inet:ip("1.2.3.4").
>>{ok,{1,2,3,4}}
>>2> inet:ip("1.2.3").
>>{ok,{1,2,0,3}}
>>3> inet:ip("1.2").
>>{ok,{1,0,0,2}}
>>4> inet:ip("1").
>>{ok,{0,0,0,1}}
> 
> 
> I can only guess this is to support the IPv6 shorthand.
> 
> --Phil
> 



More information about the erlang-questions mailing list