cross post : http://stackoverflow.com/questions/12052864/how-to-get-wildcard-address-using-getaddrinfo
I am new to perl. I am trying to fetch all the wildcard interfaces using getaddrinfo (I am using Socket6 (IO:Socket:IP somehow didn't work on my Windows box)), like:
@res = getaddrinfo('<wildcard>', 3786, AF_UNSPEC, SOCK_STREAM);
($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
print ("\nhost= $host port = $port");
I am wondering what value should I use for the placeholder <wildcard>, so that I'll get IPv4 as well IPv6 wildcard addresses (0.0.0.0 and ::) in the result, so that I can bind to it independent of the machine I am using (IPv4 or IPv6).
In 'c' specifying a null hostname pointer does the job, for perl I tried '', undef but they return loopback addresses.