[erlang-questions] IPv6

Per Hedeland per@REDACTED
Fri Mar 27 17:22:25 CET 2009


Hi,

Is there some good reason for gen_tcp/gen_udp not auto-recognizing an
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!

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}

Yeah, I can imagine that the name server had trouble finding that
"domain"... (no, it didn't actually try a DNS lookup).

--Per Hedeland



More information about the erlang-questions mailing list