getaddrinfo vs gethostbyname
From: Pierre Goyette (pierre_at_montreal.hcl.com)
Date: 06/30/04
- Next message: Rhett Gong [MSFT]: "Re: IP to username"
- Previous message: Ale_s: "libwww"
- Next in thread: Stanley Feng \(MSFT\): "Re: getaddrinfo vs gethostbyname"
- Reply: Stanley Feng \(MSFT\): "Re: getaddrinfo vs gethostbyname"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 30 Jun 2004 19:43:28 -0400
I am adding support to my application for IP V6 and have followed the
programming guidelines from Microsoft.
I replaced the call to 'gethostbyname' to 'getaddrinfo'.
The problem is that getaddrinfo doesn't seem to do what gethostbyname does.
When I call gethostbyname with the a NULL parameter, I get back a list of
all IP V4 address on my machine.
Example:
192.168.1.101
192.168.127.1
192.168.236.1
However, whenever I call getaddrinfo with the parms below (and I tried other
parms), I only seem to get a loopback address.
Hints.ai_family = PF_INET6;
Hints.ai_socktype = SOCK_STREAM;
Hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE;
rc = getaddrinfo( NULL, szListenPort6, &Hints, &AddrInfo);
I want to listen on specific addresses for my service and I don't seem to be
able to enumerate addresses for IP V6 to do this. I used
GetAdaptersAddresses to get the real addresses but never seem to be able to
connect using those addresses.
All help is greatly appreciated.
Pierre
- Next message: Rhett Gong [MSFT]: "Re: IP to username"
- Previous message: Ale_s: "libwww"
- Next in thread: Stanley Feng \(MSFT\): "Re: getaddrinfo vs gethostbyname"
- Reply: Stanley Feng \(MSFT\): "Re: getaddrinfo vs gethostbyname"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|