Results 1 to 2 of 2
Hi ,
I found the difference of returned adddress using getaddrinfo in SuSe 11 and earlier versions.
Below is the same application .
#include<stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
- 03-17-2011 #1Linux Newbie
- Join Date
- Oct 2006
- Posts
- 107
Change in getaddrinfo in SuSe 11
Hi ,
I found the difference of returned adddress using getaddrinfo in SuSe 11 and earlier versions.
Below is the same application .
#include<stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include<netdb.h>
struct sockaddr_storage clientSock;
socklen_t addrLen;
struct addrinfo hints, *result=NULL, *fullResult;
char serviceName[20];
int socketFD;
int errNum=0;
char clientIP[NI_MAXHOST];
int ret=0;
main()
{
int sockOpt=1;
memset((void *)&clientSock, 0, (sizeof (struct sockaddr_in6)));
addrLen = sizeof(clientSock);
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_PASSIVE ;
hints.ai_socktype = SOCK_STREAM;
strcpy(serviceName,"1700");
errNum = getaddrinfo(NULL,serviceName, &hints, &result);
if ( errNum < 0)
{
printf("\n Error with %s",gai_strerror(errNum));
}
for (; result!=NULL; result = result->ai_next)
{
if ( (result->ai_family == AF_INET6) || ( result->ai_family == PF_INET6))
{
printf("\n THIS is ipv6 \n");
}
else
{
printf("\n THIS is IPv4");
}
}
}
I saw output as below after execution in SuSe 11 Sp2
THIS is IPv4
THIS is ipv6
Whereas the same executable runs in earlier versions , i saw the output as below.
THIS is ipv6
THIS is IPv4
Why the getaddrinfo is returned values priority changed in SuSe 11.
Can we do change the behaviour of getaddrinfo so that it should return IPV6 and IPv4 .
Please help me out
Thanks in Advance.
- 03-17-2011 #2
Suse 11 is the commercial version, so the question could be best answered by Novell


Reply With Quote