Help with IPv6
- From: "Ravindra" <ravindra.rajaram@xxxxxxxxx>
- Date: 28 Dec 2006 23:38:53 -0800
The following piece of code always prints the output:
<OUTPUT>
The address is INADDR_ANY
The address is IN6ADDR_ANY_INIT
</OUTPUT>
<CODE>
#include<stdio.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
extern int errno;
void main(int argc,char *argv[])
{
struct addrinfo *res=NULL,hints,*temp=NULL;
int rc=0;
memset(&hints,0,sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM;
if((rc=getaddrinfo(NULL,"1900",&hints,&res))!=0)
{
fprintf(stderr,"ERROR:%s\n",gai_strerror(rc));
exit(1);
}
temp=res;
while(temp!=NULL)
{
if(temp->ai_family==PF_INET)
fprintf(stdout,"The address is INADDR_ANY\n");
else if(temp->ai_family==PF_INET6)
fprintf(stdout,"The address is
IN6ADDR_ANY_INIT\n");
temp=temp->ai_next;
}
}
</CODE>
Is there a way the order of the output can be changed? i.e I want the
IPv6 address to be reported first.
My expected output is:
<OUTPUT>
The address is IN6ADDR_ANY_INIT
The address is INADDR_ANY
</OUTPUT>
On Solaris and HP-UX, the IPv6 address is reported first. What should
be done to change the order of preference to IPv6 address on AIX ?
Thanks,
Ravindra.
.
- Prev by Date: Re: using pax in place of tar
- Next by Date: Re: port timeout
- Previous by thread: mkdev returns 1 as exit code without changing its state from Define and making available
- Next by thread: ftp put hangs
- Index(es):