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

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

Article ID : 948505
Last Review : April 18, 2008
Revision : 1.0

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:

http://msdn2.microsoft.com/en-us/library/ms738524.aspx (http://msdn2.microsoft.com/en-us/library/ms738524.aspx)

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

http://msdn2.microsoft.com/en-us/library/ms738520(VS.85).aspx (http://msdn2.microsoft.com/en-us/library/ms738520(VS.85).aspx)

Back to the top


APPLIES TO
• Windows Vista Enterprise 64-bit Edition
• Windows Vista Home Basic 64-bit Edition
• Windows Vista Home Premium 64-bit Edition
• Windows Vista Ultimate 64-bit Edition
• Windows Vista Business
• Windows Vista Business 64-bit Edition
• Windows Vista Enterprise
• Windows Vista Home Basic
• Windows Vista Home Premium
• Windows Vista Ultimate
• Windows Server 2008 Datacenter without Hyper-V
• Windows Server 2008 Enterprise without Hyper-V
• Windows Server 2008 for Itanium-Based Systems
• Windows Server 2008 Standard without Hyper-V
• Windows Server 2008 Datacenter
• Windows Server 2008 Enterprise
• Windows Server 2008 Standard

Back to the top

Keywords: 
kbprb kbtshoot kbexpertiseadvanced KB948505

Back to the top

 

Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image