[erlang-questions] IPv6

Raimo Niskanen <>
Wed Apr 1 11:24:19 CEST 2009


On Fri, Mar 27, 2009 at 05:22:25PM +0100, Per Hedeland wrote:
> Hi,
> 
> Is there some good reason for gen_tcp/gen_udp not auto-recognizing an

Not really. But as you see for gen_tcp:connect below, the inet6
option is currently required there even for an IPv6 address tuple.
These are corners we have not smoothed yet.

It can be argued that the tuple size alone is not
sufficient to determine the address class. After all
a 4-tuple can be interpreted as a IPv4-compatible
IPv6 address if you really want.

And the DUH! error 'nxdomain' that is returned
for all "other" errors should also be improved.
I will see what I can do.

> 8-tuple as an IPv6 address? gen_tcp:listen/2 and gen_udp:open/2 don't
> even fail if you give them one w/o explicit 'inet6' option, but (OS
> stack permitting) interprets "the first 4 bytes" as an IPv4 address -
> shocking behaviour for an Erlang module!

Oops! We will fix this.

> 
> Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
> Eshell V5.7  (abort with ^G)
> 1> gen_tcp:listen(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]).
> {ok,#Port<0.439>}
> 2> gen_udp:open(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]).  
> {ok,#Port<0.449>}
> 
> $ netstat -an | grep 1234
> tcp        0      0 0.1.171.205:1234            0.0.0.0:*       LISTEN
> udp        0      0 0.1.171.205:1234            0.0.0.0:*  
> 
> 'inet' may be a reasonable default (though it isn't actually documented
> as such as far as I can see), but blindly "applying" it in the face of
> obvious evidence to the contrary can't be right. gen_tcp:connect/3 and
> gen_udp:send/4 also have "interesting" behaviour:
> 
> 4> gen_tcp:connect({1,43981,4660,0,0,0,0,5}, 1234, []).
> {error,nxdomain}
> 5> gen_udp:send(S, {1,43981,4660,0,0,0,0,5}, 1234, <<"hello">>).
> {error,nxdomain}

Perhaps these should be 'badarg' exceptions since the
'inet6' option is missing...

> 
> Yeah, I can imagine that the name server had trouble finding that
> "domain"... (no, it didn't actually try a DNS lookup).
> 
> --Per Hedeland
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list