Socket...o::Emul(3pm)
β¨ NAME β¨
Socket::GetAddrInfo::Emul β bestie, this is a pure Perl emulation of getaddrinfo and getnameinfo, built on the IPv4-only legacy resolvers π¦ (the manual page you're reading rn is Socket...o::Emul(3pm), iykyk π
)
π DESCRIPTION π
Okay so here's the tea β: Socket::GetAddrInfo tries to give you the getaddrinfo and getnameinfo functions via some XS code that calls the real, actual functions living in libc. Iconic. Gorgeous. The dream. π
But sometimes that just cannot happen, and not for dramatic reasons either β maybe there's no C compiler hanging around, or maybe libc simply doesn't provide those functions at all π. When that's the case, they get emulated using the legacy resolvers like gethostbyname, etc. etc.
Heads up bestie: these emulations are not a complete replacement of the real functions, because they only support IPv4 β that's the AF_INET socket family, and nothing else. So in this case, the following restrictions apply π
πΈ getaddrinfo
- If the
familyhint is supplied, it must beAF_INET. Any other value and you're getting an error thrown bycroak. Periodt. π - The only supported
flagshint values areAI_PASSIVE,AI_CANONNAME,AI_NUMERICSERVandAI_NUMERICHOST.
The flags AI_V4MAPPED and AI_ALL are recognised but ignored, because they just don't apply to AF_INET lookups. And since this function only ever returns AF_INET addresses, it doesn't need to probe the system for configured addresses in other families β so the AI_ADDRCONFIG flag is ignored too. Not me casually ignoring three flags β¨
Lowkey important note: AI_NUMERICSERV is an extension that is not defined by RFC 2553, but most OSes provide it anyway. It is possible (though unlikely) that even the native XS implementation doesn't recognise this constant. So likeβ¦ don't be shocked if it ghosts you π
π¦ getnameinfo
- If the sockaddr family of
$addris anything other thanAF_INET, an error will be thrown withcroak. No exceptions, no negotiation, no vibe check. π - The only supported
$flagsvalues areNI_NUMERICHOST,NI_NUMERICSERV,NI_NOFQDN,NI_NAMEREQDandNI_DGRAM.
π IDN SUPPORT π
This pure-perl emulation does provide the IDN constants such as AI_IDN and NI_IDN β yes, they're there, they exist, they're giving main character energy π β but the getaddrinfo and getnameinfo functions will croak if you actually pass these flags in. π
Why is that a slay, you ask? Because it lets a program probe for their support and then gracefully fall back to some other behaviour instead. That's the whole point, bestie π«Ά
β AUTHOR β
Paul Evans <leonerd@leonerd.org.uk>
That's the whole page, fr fr π β brought to you by User Contributed Perl Documentation, perl v5.40.0, dated 2025-02-01. Go forth and resolve responsibly, queen πβ¨
π¦ where this page comes from
- debian trixie: libsocket-getaddrinfo-perl 0.22-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsocket-getaddrinfo-perl 0.22-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsocket-getaddrinfo-perl 0.22-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms