I'm not quite sure what the best behavior is in this case - you have DNS
answering for IPv6 for the name "localhost" and you have the Socket6
libraries installed but you don't have IPv6 enabled.
Seems like if you don't have IPv6 enabled then DNS shouldn't be
resolving that name either - seems a little broken to have one but not
the other (they are two different systems DNS vs local protocols - but
by using a non-address hostname both systems have to get used). By
passing a name instead of an address you are asking Net::Server to
resolve the name - which in this case resulted in an IPv4 address and an
IPv6 address - which was resolved using IPv6 libraries on the system.
You are the first I've heard from with this particular problem (all of
the libraries+DNS but IPv6 not actually enabled).
About the closest I could see us coming to fixing your particular
problem is allowing for a warn without a die if a hostname resolved to
both ipv4 and ipv6 and you are on a system (like the bsds) that tend to
have sysctl bind-ipv6-only=1, but the ipv6 could not be bound. Do you
have a fast way to check if ipv6 is enabled on bsd without actually
attempting to bind a port?
Up until 2.005, I had adopted the behavior of not binding ipv6 unless
asked. However, slow as it may be, the world is migrating towards ipv6
and we have people using Net::Server that only have ipv6 addresses on
their hosts. They and others raised very good points that if you are
passing in a hostname (not a ipv4 or a ipv6 address), it should bind to
what is returned by the hostname lookup - so if your hostname lookup
returns ipv6, it should try and bind it.
There are plenty of arguments to be had on both sides of the issue.
Paul
On Wed Jul 18 11:04:43 2012, VKHERA wrote:
Show quoted text> On a server without IPv6 enabled (FreeBSD 8.2 in this case)
> Net::Server will not start a
> server because it attempts to bind to the IPv6 address if it finds the
> supported
> modules. The changelog for 2.006 indicates this is a specifically
> handled case, but it
> seems not.
>
>
> [mmstaging]~% perl -e 'use base qw(Net::Server); main->run(host =>
> "localhost")'
> 2012/07/18-10:57:51 main (type Net::Server) starting! pid(36856)
> Resolved [localhost]:20203 to [::1]:20203, IPv6
> Resolved [localhost]:20203 to [127.0.0.1]:20203, IPv4
> Binding to TCP port 20203 on host ::1 with IPv6
> 2012/07/18-10:57:51 Can't connect to TCP port 20203 on ::1 [Protocol
> not
> supported]
> at line 67 in file
> /usr/local/lib/perl5/site_perl/5.14.2/Net/Server/Proto/TCP.pm
> 2012/07/18-10:57:51 Server closing!
>
> "localhost" resolves to just 127.0.0.1, nothing else. I do not know
> how it is finding
> ":;1" above:
>
> [mmstaging]~% host localhost
> localhost.m1e.net has address 127.0.0.1
>
>
> Workaround is to explicitly request IPv4 for now.