Re: IPv6-capable hostname lookup in ext/standard

From: Date: Thu, 26 Nov 2026 11:30:30 +0000
Subject: Re: IPv6-capable hostname lookup in ext/standard
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-133225@lists.php.net to get a copy of this message
Hi On 2026-11-13 18:44, David CARLIER wrote:
I'd like to add a new function for master, something like: function gethostaddresses(string $hostname, int $family = DNS_A | DNS_AAAA): array|false {} It returns the address strings in getaddrinfo() order, or false on failure. It goes through the system resolver like stream connections do. $family reuses DNS_A/DNS_AAAA, since the AF_* constants live in ext/sockets. php_network_getaddresses() already wraps getaddrinfo(), so the change is small and fits with the resolver cleanup in GH-15555.
The API is not great, but it seems to be reasonably consistent with what we have now and it is a good short term fix. In the long run, we probably what to create something clean and well-designed in Io\Dns or something.
Kind of open questions: 1. Naming: a new function, or a new parameter on gethostbynamel()?
New function makes sense to me so that we can just default to both families.
2. Should $family take the DNS_* constants, or should ext/standard get its own constants?
The DNS_* constants are already in standard from what I see: https://github.com/php/php-src/blob/eb9aebeee7be34c8957bb1f36977cbc1ec137765/ext/standard/basic_functions.stub.php#L454 I wonder though if we need the $family parameter at all. If necessary folks can just filter_var() for the specific family they need. If you keep the parameter, please make sure to add strict validation. Best regards Tim Düsterhus

« previous php.internals (#133225) next »