Networking Forums

Networking Forums > Computer Networking > Windows Networking > getaddrinfo return only one IP address

Reply
Thread Tools Display Modes

getaddrinfo return only one IP address

 
 
Rajesh Gupta
Guest
Posts: n/a

 
      07-22-2008, 11:59 PM
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);



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't get multi-homed host address using getaddrinfo() Options Arthur Linux Networking 2 07-20-2007 09:02 AM
Is it possible for someone to use a fake return email address? mail1227418@lawrabbit.com Linux Networking 10 03-17-2007 12:34 PM
wrong return address John I-Chung Wang Linux Networking 0 10-27-2004 05:50 AM
Why does getaddrinfo return only one address? David Linux Networking 1 12-19-2003 08:50 AM
Spammer is using my domain as a return address (HELP) Anthony Broadband 43 11-20-2003 07:33 PM



1 2 3 4 5 6 7 8 9 10 11