NAME
Socket::GetAddrInfo::Emul - Pure Perl emulation of getaddrinfo and getnameinfo using IPv4-only legacy resolvers
DESCRIPTION
Socket::GetAddrInfo attempts to provide the getaddrinfo and getnameinfo functions by some XS code that calls the real functions in libc. If for some reason this cannot be done; either there is no C compiler, or libc does not provide these functions, then they will be emulated using the legacy resolvers gethostbyname, etc... These emulations are not a complete replacement of the real functions, because they only support IPv4 (the AF_INET socket family). In this case, the following restrictions will apply.
getaddrinfo
If the
familyhint is supplied, it must beAF_INET. Any other value will result in an error thrown bycroak.The only supported
flagshint values areAI_PASSIVE,AI_CANONNAME,AI_NUMERICSERVandAI_NUMERICHOST.The flags
AI_V4MAPPEDandAI_ALLare recognised but ignored, as they do not apply toAF_INETlookups. Since this function only returnsAF_INETaddresses, it does not need to probe the system for configured addresses in other families, so theAI_ADDRCONFIGflag is also ignored.Note that
AI_NUMERICSERVis an extension not defined by RFC 2553, but is provided by most OSes. It is possible (though unlikely) that even the native XS implementation does not recognise this constant.
getnameinfo
If the sockaddr family of
$addris anything other thanAF_INET, an error will be thrown withcroak.The only supported
$flagsvalues areNI_NUMERICHOST,NI_NUMERICSERV,NI_NOFQDN,NI_NAMEREQDandNI_DGRAM.
IDN SUPPORT
This pure-perl emulation provides the IDN constants such as AI_IDN and NI_IDN, but the getaddrinfo and getnameinfo functions will croak if passed these flags. This should allow a program to probe for their support, and fall back to some other behaviour instead.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>