This is a discussion on multicast join group error : No such device within the Linux Networking forums, part of the Linux Forums category; Hi, One of my multicast program dies on a specific set of machines with error No such Device when I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, One of my multicast program dies on a specific set of machines with error No such Device when I try to join the multicast group with setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, ...); The machines in question are running RHEL 3.0 (2.4.21-4ELsmp) and I also checked to find that multicast is enabled. Any pointers to resolve the issue is appreciated. I have attached a test program that reproduces the error. Thanks! #include <stdio.h> #include <stdlib.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <errno.h> #include <string.h> int main(void) { int sock; int one; int ret; struct sockaddr_in sock_addr; struct hostent *hent; struct ip_mreqn mreq; sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if(sock < 0) { perror("\nError in socket creation"); exit(errno); } memset(&sock_addr, 0, sizeof(sock_addr)); sock_addr.sin_family = AF_INET; sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); sock_addr.sin_port = 0; one = 1; ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)); if(ret < 0) { perror("\nError in reusing addr"); exit(errno); } ret = bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)); if(ret < 0) { perror("\nError in bind"); exit(errno); } hent = gethostbyname("224.1.1.11"); if(!hent) { perror("\nInvalid address"); exit(errno); } memset(&sock_addr, 0, sizeof(sock_addr)); sock_addr.sin_family = AF_INET; memcpy(&sock_addr.sin_addr.s_addr, hent->h_addr, hent->h_length); if(!IN_MULTICAST(ntohl(sock_addr.sin_addr.s_addr)) ) { perror("\nInvalid address"); exit(errno); } /* Join the multicast group */ memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr.s_addr = sock_addr.sin_addr.s_addr; mreq.imr_address.s_addr = htonl(INADDR_ANY); ret = setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); if(ret<0) { perror("\nCannot join multicast group"); exit(errno); } return 0; } |
|
|||
|
"Pirabhu Raman" <pirabhur@ufl.edu> writes:
> mreq.imr_multiaddr.s_addr = sock_addr.sin_addr.s_addr; > mreq.imr_address.s_addr = htonl(INADDR_ANY); Set imr_address to something other than zero. You need to specify the address of the interface on which you want to join this multicast group -- using the local address for broadcast-type interfaces, and the remote address for point-to-point interfaces. -- James Carlson, IP Systems Group <james.d.carlson@sun.com> Sun Microsystems / 1 Network Drive 71.234W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.497N Fax +1 781 442 1677 |
|
|||
|
"James Carlson" <james.d.carlson@sun.com> wrote in message news:xoavbre8h7og.fsf@sun.com... > "Pirabhu Raman" <pirabhur@ufl.edu> writes: > > mreq.imr_multiaddr.s_addr = sock_addr.sin_addr.s_addr; > > mreq.imr_address.s_addr = htonl(INADDR_ANY); > > Set imr_address to something other than zero. You need to specify the > address of the interface on which you want to join this multicast > group -- using the local address for broadcast-type interfaces, and > the remote address for point-to-point interfaces. Thanks for the response. That fixed the issue. Thanks! |