Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Tue, 22 Jul 2008 16:54:22 -0700,    group: microsoft.public.platformsdk.networking        back       


getaddrinfo return only one IP address   
All,

I am using the new Windows Function to resolve the machine name. My target 
machine has two IP address 10.2.x.x and 10.3.x.x. The name of my machine is 
Server-2003. When I tried to resolve the machine name using getaddrinfo API, 
it only returned 10.2.x.x Ip address. I do not see any other IP address in 
the list and there is only one element in the list. Next is empty?

What is the reason for that? How can I resolve the machine name to all the 
IP addresses? I do not have credentials for the remote system.

char* ip = "Server-2003";
char* port = "27015";
struct addrinfo aiHints;
struct addrinfo *aiList = NULL;
int retVal;
char* pIPAddress;

pIPAddress = new char [16];

WORD wVersionRequested;
   WSADATA wsaData;
    int err;


    wVersionRequested = MAKEWORD(2, 2);

    err = WSAStartup(wVersionRequested, &wsaData);
    if (err != 0) {
        // Tell the user that we could not find a usable
		// Winsock DLL.
        printf("WSAStartup failed with error: %d\n", err);
        return 1;
    }


	//--------------------------------
	// Setup the hints address info structure
	// which is passed to the getaddrinfo() function
	memset(&aiHints, 0, sizeof(aiHints));
	aiHints.ai_family = AF_INET;
	aiHints.ai_socktype = SOCK_STREAM;
	aiHints.ai_protocol = IPPROTO_TCP;
if ((retVal = getaddrinfo(ip, port, &aiHints, &aiList)) != 0) {
  printf("getaddrinfo() failed.\n");
}
in_addr SocketAddr;

SocketAddr.S_un = ((struct sockaddr_in *)(aiList->ai_addr))->sin_addr.S_un;

printf("ip address : %s\n", inet_ntoa(SocketAddr));

freeaddrinfo(aiList);
date: Tue, 22 Jul 2008 16:54:22 -0700   author:   Rajesh Gupta

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us