getaddrinfo does not resolve IPV6 address RRS feed

  • Question

  • Hi


    I am facing a issue with getaddrinfo API, this API works as expected and resolve the boht IPV4 and IPV6 address

    If the hostname passed is of the local machine.


    But when a Remote hostname is passed as input to this API, it returns only the IPV4 Address and does not

    Return any IPV6 address.


    Here the Remote Host is a Win2008 R2, which has both IPV4 and IPV6 address.


       ZeroMemory( &hints, sizeof(hints) );

       hints.ai_family = AF_UNSPEC;

       hints.ai_socktype = SOCK_STREAM;


       dwRetval = getaddrinfo(SOMEHOSTNAME, NULL, &hints, &result);

       if ( dwRetval != 0 ) {

           printf("getaddrinfo failed with error: %d\n", dwRetval);


           return 1;






    Friday, April 16, 2010 6:15 AM

All replies

  • Does windows ping utility  able to resolve the address?
    Monday, April 19, 2010 8:46 AM
  • I am facing a similar problem on Windows 7, the surprising thing is

    - When I pass an alias (a CNAME DNS record) to the getaddrinfo function with AF_UNSPEC and  AI_CANONNAME I only get IPv4 addresses

    - When I do a nslookup on the alias i get all IP addresses

    - When I pass an the host name to the getaddrinfo function with AF_UNSPEC and  AI_CANONNAME I get all the addresses

    Does any one have an idea why?

    - NYA

    Thursday, October 18, 2012 4:53 PM