multicast join group error : No such device

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 ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-05-2004
Pirabhu Raman
 
Posts: n/a
Default multicast join group error : No such device


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
  #2 (permalink)  
Old 11-08-2004
James Carlson
 
Posts: n/a
Default Re: multicast join group error : No such device

"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
Reply With Quote
  #3 (permalink)  
Old 11-09-2004
Pirabhu Raman
 
Posts: n/a
Default Re: multicast join group error : No such device


"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!


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:28 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0