vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |