Originally posted by: Dritter29
Hello,
I'm attempting to create a multicast socket with IPv6 on an AIX 5.3 server. When I call the secsockopt function it returns the following error:
Can't assign requested address
I'm attempting to create the multicast connection on address ff02::1
Here is my code snippet
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <stdio.h> #include <unistd.h> #define PORT 12345 #define GROUP
"ff02::1" #define MSGBUFSIZE 256
void sendMsg(struct sockaddr_in6* sa); main(
int argc,
char *argv[])
{ struct sockaddr_in6 addr, addr2;
int fd, fd2, nbytes; #
if defined(__HP_aCC)
int addrlen; #
else socklen_t addrlen; #endif struct ipv6_mreq mreq;
char msgbuf[MSGBUFSIZE];
/* create what looks like an ordinary UDP socket */
if ((fd=socket(AF_INET6,SOCK_DGRAM,IPPROTO_UDP)) < 0)
{ perror(
"socket"); exit(1);
}
/* set up destination address */ memset(&addr,0,sizeof(addr)); addr.sin6_family=AF_INET6; addr.sin6_addr=in6addr_any;
//inet_pton(AF_INET6, "::1", &addr.sin6_addr); addr.sin6_port=htons(PORT);
/* bind to receive address */
if (bind(fd,(struct sockaddr *) &addr,sizeof(addr)) < 0)
{ perror(
"bind"); exit(1);
} memset(&addr2, 0, sizeof(addr2)); addr2.sin6_family = AF_INET6; addr2.sin6_port = htons(PORT); inet_pton(AF_INET6, GROUP, &addr2.sin6_addr); memset(&mreq, 0, sizeof(mreq)); memcpy( &mreq.ipv6mr_multiaddr, &(addr2.sin6_addr), sizeof(struct in6_addr)); mreq.ipv6mr_interface=0;
if (setsockopt(fd,IPPROTO_IPV6,IPV6_JOIN_GROUP,&mreq,sizeof(mreq)) < 0)
{ perror(
"setsockopt join group"); exit(1);
}
// disconnect and client test code follows
return 0;
}
Am I doing something incorrect? Is our server not configured correctly? I can create an IPv4 multicast connection with no problem, but not an IPv6 one.
Any advice or suggestions would be greatly appreciated.
Thanks,
Dave Ritter