Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The gethostbyname function unexpectedly returns the IP addresses in numeric order on a Windows Vista-based computer or on a Windows Server 2008-based computer


View products that this article applies to.

Symptoms

Consider the following scenario:
  • You are running a Windows Vista-based computer or a Windows Server 2008-based computer.
  • The computer has multiple IP addresses.
  • You run the gethostbyname function.
In this scenario, the gethostbyname function returns the IP addresses in numeric order. Therefore, the IP address that has the lowest number is returned first. You expect the primary IP address to be returned first.

↑ Back to the top


Cause

The concept of a primary IP address does not exist in Windows Vista or in Windows Server 2008. Therefore, this behavior is by design.

↑ Back to the top


More information

The gethostbyname function has been deprecated. We recommend that you use the getaddrinfo function instead. However, we still cannot guarantee that primary IP address will be returned first.

For more information about the gethostbyname function, visit the following Microsoft Web site:For more information about the getaddrinfo function, visit the following Microsoft Web site:

↑ Back to the top


Keywords: kbprb, kbtshoot, kbexpertiseadvanced, KB948505

↑ Back to the top

Article Info
Article ID : 948505
Revision : 1
Created on : 4/18/2008
Published on : 4/18/2008
Exists online : False
Views : 272