Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

can't get multi-homed host address using getaddrinfo() Opt..

 
   Soft32 Home -> Linux2 Arch -> Networking RSS
Next:  odd network traffic?  
Author Message
Arthur

External


Since: Jul 16, 2007
Posts: 1



(Msg. 1) Posted: Mon Jul 16, 2007 6:52 pm
Post subject: can't get multi-homed host address using getaddrinfo() Options
Archived from groups: comp>os>linux>networking (more info?)

I'm using getaddrinfo("test.domain.com", NULL, &hint, &info) to
get IP addresses.

Below is /etc/hosts:
....
10.200.28.120 test.domain.com
172.0.20.120 test.domain.com
....

The problem is getaddrinfo always return only one IP address
10.200.28.120. From the man page, I think I should get a address
linked list
that mean I can get both.

Please see my demo code below:
int main()
{
struct addrinfo hints;
struct addrinfo *info;
int s;
memset((char*) &hints, '\0', sizeof(hints));
hints.ai_family = AF_INET; // just IPv4 for now
hints.ai_socktype = SOCK_STREAM; // just TCP
s = getaddrinfo("test.domain.com", NULL, &hints, &info);
if (s != 0) { printf ("error\n"); }
printf ("ok\n");
return 0;
}

I have checked info->ai_next with gdb, it's always NULL. Is there
anything wrong in my demo code? My platform it RHEL 4.0.

BTW: This demo code can get the right result on Solaris.

Thanks

Arthur
Back to top
Login to vote
Doug Laidlaw

External


Since: Aug 01, 2007
Posts: 31



(Msg. 2) Posted: Thu Jul 19, 2007 10:32 am
Post subject: Re: can't get multi-homed host address using getaddrinfo() Options [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Arthur wrote:

> I'm using getaddrinfo("test.domain.com", NULL, &hint, &info) to
> get IP addresses.
>
> Below is /etc/hosts:
> ...
> 10.200.28.120 test.domain.com
> 172.0.20.120 test.domain.com
> ...
>
> The problem is getaddrinfo always return only one IP address
> 10.200.28.120. From the man page, I think I should get a address
> linked list
> that mean I can get both.
>
> Please see my demo code below:
> int main()
> {
> struct addrinfo hints;
> struct addrinfo *info;
> int s;
> memset((char*) &hints, '\0', sizeof(hints));
> hints.ai_family = AF_INET; // just IPv4 for now
> hints.ai_socktype = SOCK_STREAM; // just TCP
> s = getaddrinfo("test.domain.com", NULL, &hints, &info);
> if (s != 0) { printf ("error\n"); }
> printf ("ok\n");
> return 0;
> }
>
> I have checked info->ai_next with gdb, it's always NULL. Is there
> anything wrong in my demo code? My platform it RHEL 4.0.
>
> BTW: This demo code can get the right result on Solaris.
>
> Thanks
>
> Arthur

Can one domain have two addresses? I think that the multiple addresses that
ISPs use all have slightly different domain names (for example,
hotkey.net.au is boomer.hotkey.net.au. Another IP is frog. Something else
is duckula.) and are linked to one another. But I don't really know.

Doug.
--
Orthodoxy is my doxy; heterodoxy is your doxy.
- Wm Warburton, 18th c. Bishop of Gloucester.
Back to top
Login to vote
Philippe WEILL

External


Since: Nov 05, 2004
Posts: 61



(Msg. 3) Posted: Fri Jul 20, 2007 11:02 am
Post subject: Re: can't get multi-homed host address using getaddrinfo() Options [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Doug Laidlaw wrote:
> Arthur wrote:
>
>> I'm using getaddrinfo("test.domain.com", NULL, &hint, &info) to
>> get IP addresses.
>>
>> Below is /etc/hosts:
>> ...
>> 10.200.28.120 test.domain.com
>> 172.0.20.120 test.domain.com
>> ...
>>
>> The problem is getaddrinfo always return only one IP address
>> 10.200.28.120. From the man page, I think I should get a address
>> linked list
>> that mean I can get both.
>>
>> Please see my demo code below:
>> int main()
>> {
>> struct addrinfo hints;
>> struct addrinfo *info;
>> int s;
>> memset((char*) &hints, '\0', sizeof(hints));
>> hints.ai_family = AF_INET; // just IPv4 for now
>> hints.ai_socktype = SOCK_STREAM; // just TCP
>> s = getaddrinfo("test.domain.com", NULL, &hints, &info);
>> if (s != 0) { printf ("error\n"); }
>> printf ("ok\n");
>> return 0;
>> }
>>
>> I have checked info->ai_next with gdb, it's always NULL. Is there
>> anything wrong in my demo code? My platform it RHEL 4.0.
>>
>> BTW: This demo code can get the right result on Solaris.
>>
>> Thanks
>>
>> Arthur
>
> Can one domain have two addresses?
yes

host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 209.85.129.147
www.l.google.com has address 209.85.129.99
www.l.google.com has address 209.85.129.104
www.google.com is an alias for www.l.google.com.


> I think that the multiple addresses that
> ISPs use all have slightly different domain names (for example,
> hotkey.net.au is boomer.hotkey.net.au. Another IP is frog. Something else
> is duckula.) and are linked to one another. But I don't really know.
>
> Doug.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How do I get new IP address in a Multi cast group? - Hi there!I m building a program using udp sockets.I stack in the part of getting a new IP when a new node trying to get...

Host to host NIC bonding works only in one direction - I am trying to set up a host-to-host link (no switch) between two ubuntu machines. I would like to use NIC bonding so..

Host-To-Host Data Sharing via Modem - Here's my conundrum - I have a remote base node (Slackware 11) of a sensor network which aggregates data collected from...

IPR2 + Netfilter: stateful _routing_ on inbound DNAT, in d.. - Dear Everyone, I'm preparing to upgrade our firewall. We're a small business with a fairly basic IP networking setup.....

MAC address of an IPv6 address - Hi All, I am writing a program that tests the health of a NIC card. I am creating a NDD socket (Data Link Access) whic...

name based virtual host - Is it possible to create a ssl enabled name based virtual host ?
       Soft32 Home -> Linux2 Arch -> Networking All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
 Linux
 Mac
 PDA



[ Contact us | Terms of Service/Privacy Policy ]