Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006
    Posts
    264

    Question gethostbyname vs getaddrinfo

    In PHP, which is better to use to handle both ipv4 and ipv6?:

    gethostbyname
    or
    getaddrinfo

  2. #2
    Join Date
    Apr 2009
    Location
    Pittsburgh, Pennsylvania
    Posts
    582
    Quote Originally Posted by ryan14 View Post
    In PHP, which is better to use to handle both ipv4 and ipv6?:

    gethostbyname
    or
    getaddrinfo
    gethostbyname - ipv4 only...

    and getaddrinfo doesn't even exist as a php function, unless im blind, which may be the case, i'm tired.

    have a look at http://www.weberdev.com/get_example-3921.html

  3. #3
    Join Date
    Apr 2007
    Location
    Calgary, Canada
    Posts
    200
    no, getaddrinfo is not a PHP function. (Read the wiki entry on 'getaddrinfo')

    As for getting IPv6 addresses from a hostname, you will need to look at the dns_get_record function. This is because gethostbyname will always return a IPv4 address. If you do use dns_get_record, you must pass in DNS_AAAA as the type as the second parameter to find the IPv6 address of the hostname.

    Good luck!

Similar Threads

  1. This is for all you "php_network_getaddresses: getaddrinfo failed:" sufferers
    By magneticmg in forum Hosting Security and Technology
    Replies: 13
    Last Post: 04-14-2008, 01:33 PM
  2. getaddrinfo failed error
    By webzila in forum Hosting Security and Technology
    Replies: 4
    Last Post: 06-19-2005, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •