Hello there
I am working on Digi Connect Me 9210
What I want to do is very simple, I have a multicast device and I need to receive the udp packets from this device, so ‘udp multicasting receiver’ but I cannot join the range that is multicasting by the device.
mreq.imr_multiaddr.s_addr = NAInet_addr (VALUE_MULTICAST_POINTER);
mreq.imr_interface.s_addr = INADDR_ANY;
new_CallStatus = setsockopt (new_multi_server_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) & mreq, sizeof (mreq));
new_CallStatus always return -1;
So what should I think?
- Connect me 9210 doesn’t support multicasting?
- Is there a logical error in the code I wrote?
- Should i go another way to enable multicasting on Connect me 9210?
new_multi_server_sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if(new_multi_server_sock<0){
perror("Socket Creation Failed
");
return ;
}
new_CallStatus=setsockopt(new_multi_server_sock,SOL_SOCKET,SO_REUSEADDR,(const char *)&new_optval,sizeof(int));
if(new_CallStatus<0){
perror("Setsockopt Failed
");
return ;
}
new_CallStatus=setsockopt(new_multi_server_sock,SOL_SOCKET,SO_RCVBUF,(char *)&new_sockbufsize,sizeof(int));
if(new_CallStatus<0){
perror("Setsockopt Failed
");
return ;
}
new_multi_portno=INTVAL_MULTICAST_PORT_NUMBER;
memset((char *)&new_multi_server_addr,0,sizeof(new_multi_server_addr));
new_multi_server_addr.sin_family=AF_INET;
new_multi_server_addr.sin_addr.s_addr=htonl(INADDR_ANY);
new_multi_server_addr.sin_port=htons((unsigned short)new_multi_portno);
new_CallStatus=bind(new_multi_server_sock,(struct sockaddr *)&new_multi_server_addr,sizeof(new_multi_server_addr));
if(new_CallStatus<0){
perror("New Creation Socket for multicasting cannot binding the port
");
return ;
}
else{
printf("New Creation Multicasting socket successfuly binding the port so socket ready to read
");
}
mreq.imr_multiaddr.s_addr = NAInet_addr(VALUE_MULTICAST_POINTER);
mreq.imr_interface.s_addr = INADDR_ANY;
new_CallStatus=setsockopt(new_multi_server_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,(char *)&mreq,sizeof(mreq));
if(new_CallStatus<0){
return ;
}
else{
printf("success");
}