[RFC][VOTE]: Implement socket_getaddrinfo family

php.internals

David Walker

10 years ago
Hi, I'd like to open voting on my RFC[1] to implement getaddrinfo(). The RFC implements 4 new socket extension functions to aid in the calling, examining, and connect/binding of the addrinfo structure.
-- Dave [1] - https://wiki.php.net/rfc/socket_getaddrinfo

Bishop Bettini

10 years ago
On Wed, Aug 24, 2016 at 11:26 AM, David Walker <dave@mudsite.com> wrote:
> I'd like to open voting on my RFC[1] to implement getaddrinfo(). The RFC > implements 4 new socket extension functions to aid in the calling, > examining, and connect/binding of the addrinfo structure. >
+1 from me -- let the OS do the lookups. Would you please add example usage and output of socket_addrinfo_explain to the RFC, as that'll drive documentation creation? Also, it may be beneficial to elaborate on the scenarios where socket_addrinfo is easier to use than socket_* and friends (getservbyname for example) and the costs of that ease (eg, behind the scenes DNS queries).

David Walker

10 years ago
On Wed, Aug 24, 2016 at 9:48 AM Bishop Bettini <bishop@php.net> wrote:
> Also, it may be beneficial to elaborate on the scenarios where >> socket_addrinfo is easier to use than socket_* and friends (getservbyname >> for example) and the costs of that ease (eg, behind the scenes DNS queries). > >
Most of the get*by* network related functions are all pretty much wrapped around IPv4 at the transport layer, for example gethostbyname. Specifically[1] there are comments that explain how to implement in userland a gethostbyname6 for IPv6 related lookups. getaddrinfo, and it's inverse getnameinfo, are more modern network interfaces to POSIX that allow us to develop with (generally) transport layer agnostic. As to a specific example case: if I accept user input to connect to a remote site (bear with me here on security implications), I shouldn't need to know if the remote site is v4, or v6 specific. Maybe we're doing a down-detector site and the user input was ipv6.facebook.com, which has no A record, but does have a AAAA record. It's cleaner and easier to just let getaddrinfo figure it out for you.
-- Dave [1] - http://php.net/manual/en/function.gethostbyname.php#70936

Derick Rethans

10 years ago
On Wed, 24 Aug 2016, David Walker wrote:
> I'd like to open voting on my RFC[1] to implement getaddrinfo(). The > RFC implements 4 new socket extension functions to aid in the calling, > examining, and connect/binding of the addrinfo structure.
Sorry, I missed this discussion. Is there a reason why addrinfo is a resource, and not an object? I realize resources are needed for the actual socket, but is it needed for the addrinfo information? I would also like to see (in the RFC, but certainly in the docs), how this works connecting to a specific IPv6 address resource. cheers, Derick

David Walker

10 years ago
On Wed, Aug 24, 2016 at 9:58 AM Derick Rethans <derick@php.net> wrote:
> On Wed, 24 Aug 2016, David Walker wrote: > > > I'd like to open voting on my RFC[1] to implement getaddrinfo(). The > > RFC implements 4 new socket extension functions to aid in the calling, > > examining, and connect/binding of the addrinfo structure. > > Sorry, I missed this discussion. Is there a reason why addrinfo is a > resource, and not an object? I realize resources are needed for the > actual socket, but is it needed for the addrinfo information? > > I would also like to see (in the RFC, but certainly in the docs), how > this works connecting to a specific IPv6 address resource. > > cheers, > Derick >
I did message internals a couple weeks back about it, was limited discussion so it was probably missed. I will be adding the _explain example for bishop, and can add an IPv6 example for you too. I went with a resource as addrinfo is itself a structure, which has general information including a pointer to the actual sockaddr to use. I, maybe preemptively, assumed the general use-case would be to use the addrinfo for the sockaddr rather than the general hint-information returned as well. As one ought not to care about how I can connect as long as libc says it should work. And if you had a specific family, or protocol you wanted to connect over, you can always provide the hint to get at it.
-- Dave

David Walker

10 years ago
On Wed, Aug 24, 2016 at 9:26 AM David Walker <dave@mudsite.com> wrote:
> Hi, > > I'd like to open voting on my RFC[1] to implement getaddrinfo(). The RFC > implements 4 new socket extension functions to aid in the calling, > examining, and connect/binding of the addrinfo structure. > > -- > Dave > > [1] - https://wiki.php.net/rfc/socket_getaddrinfo >
Hi, RFC vote has finished. Was accepted 9-0 for PHP 7.2. Thanks to all for discussion & voting. Would someone with vcs be able to merge into master (or wherever it would need to go for 7.2) - Dave

Christoph Becker

9 years ago
On 01.09.2016 at 02:12, David Walker wrote:
> On Wed, Aug 24, 2016 at 9:26 AM David Walker <dave@mudsite.com> wrote: > >> I'd like to open voting on my RFC[1] to implement getaddrinfo(). The RFC >> implements 4 new socket extension functions to aid in the calling, >> examining, and connect/binding of the addrinfo structure. >> >> [1] - https://wiki.php.net/rfc/socket_getaddrinfo > > RFC vote has finished. Was accepted 9-0 for PHP 7.2. > > Thanks to all for discussion & voting. Would someone with vcs be able to > merge into master (or wherever it would need to go for 7.2)
I have merged the PR into master (what's indeed the proper branch for 7.2), and also adjusted the RFC accordingly. Thanks for the RFC and the implementation, Dave!
-- Christoph M. Becker