Networking Forums

Networking Forums > Computer Networking > Linux Networking > multicast join group error : No such device

Reply
Thread Tools Display Modes

multicast join group error : No such device

 
 
Pirabhu Raman
Guest
Posts: n/a

 
      11-05-2004, 09:16 PM

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;
}



 
Reply With Quote
 
 
 
 
James Carlson
Guest
Posts: n/a

 
      11-08-2004, 11:00 AM
"Pirabhu Raman" <(E-Mail Removed)> 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 <(E-Mail Removed)>
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
 
Reply With Quote
 
Pirabhu Raman
Guest
Posts: n/a

 
      11-09-2004, 02:38 PM

"James Carlson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Pirabhu Raman" <(E-Mail Removed)> 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!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi to ALL. I just join this group. jesicalydahas@gmail.com Broadband 4 12-19-2007 04:33 PM
Join multicast group tool? response3 Linux Networking 2 11-13-2007 09:55 PM
HOW DO I JOIN A WAN GROUP? INDEE Wireless Networks 2 10-10-2005 02:13 PM
Source IP Address of Multicast Join Packets nd_no@yahoo.com Linux Networking 4 03-03-2005 10:35 AM
IPRIP could not join the multicast group 224.0.0.9 Scot Wireless Networks 0 12-12-2004 06:29 PM



1 2 3 4 5 6 7 8 9 10 11