About Inets and httpd_utils:ip_address/2

Roberto Aloi <>
Wed Oct 21 19:05:44 CEST 2009


Hi all,

playing a bit with Inets and Erlang Web, my attention went to the  
"httpd_utils" module in inets.
In the ip_address/2 function (last clause), you bind the Inet variable  
to "inet" or "inet6", according to the result of the following piece  
of code:

Inet = case gen_tcp:listen(0, [inet6]) of
	       {ok, Dummyport} ->
		   gen_tcp:close(Dummyport),
		   inet6;
	       _ ->
		   inet
	   end,

Now, on my laptop (Mac OS X 10.6), the listen and the close operations  
both succeed, so I get:

Inet = inet6.

Still,

inet:getaddr("0.0.0.0", inet6).

will fail on my machine, returning:
{error, nxdomain}.

By replacing "inet6" with "inet" I get (as expected):
{ok, {0,0,0,0}}.

This strange (at least for me) behavior, resulted into my Erlang Web  
installation not understanding a:

BindAddress 0.0.0.0

directive in my inets.conf file.

Is this an expected behaviour?

Regards,

Roberto Aloi

http://www.erlang-consulting.com
---



More information about the erlang-bugs mailing list