Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(IP_MULTICAST_IF) Multicast and Linux !?

684 views
Skip to first unread message

Marco Basile

unread,
Jun 17, 1998, 3:00:00 AM6/17/98
to
Hi there, is there anyone who can suggest me how to fix this problem? I've just tried to implement a client that send datagrams to a multicast address (224.0.0.11). Basically the source code you find below it's a function that creates a socket and set IP_MULTICAST_IF flag at the IP level of the socket. When a try to run it I get the following message: "initsocketss(): setsockopt IP_MULTICAST_IF failed: Cannot assign requested address" I read some messages in the newsgroup about people having the same problem, but I didn't find any answer. Other steps that I followed were: > ifconfig [bla .. bla ..] multicast > route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0 I'm using Linux Red Had 2.0.31 Do you have any idea about what I missed !? Thanx a lot. /Marco ________________________________________________________________________ void initsockets(){ struct ip_mreq imr; int enable = 1; imr.imr_multiaddr.s_addr = inet_addr(ALLMOBAGENTS);/* 224.0.0.11 */ /* If no interface is specified then the interface leading to the default route is used.*/ imr.imr_interface = terminalIPaddress; RegisterMesckt = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); if (setsockopt(RegisterMesckt,SOL_SOCKET,SO_REUSEADDR,&enable,sizeof(int)) < 0){ printf ("Error setting REUSEADDR option \n"); exit(-1); } if (setsockopt(RegisterMesckt, IPPROTO_IP, IP_MULTICAST_IF (char *)&imr, sizeof(struct ip_mreq)) < 0) { perror("initsockets(): setsockopt IP_MULTICAST_IF failed"); exit(-1); }

Stephen Crane

unread,
Jun 18, 1998, 3:00:00 AM6/18/98
to

Marco Basile <Marco....@era.ericsson.se> writes:

> Hi there,
> is there anyone who can suggest me how to fix this problem?
> I've just tried to implement a client that send datagrams to a multicast
> address
> (224.0.0.11).
> Basically the source code you find below it's a function that creates a
> socket and set IP_MULTICAST_IF flag at the IP level of the socket.
> When a try to run it I get the following message:
> "initsocketss(): setsockopt IP_MULTICAST_IF failed: Cannot assign
> requested address"
> I read some messages in the newsgroup about people having the same
> problem, but I didn't find any answer.
> Other steps that I followed were:
> > ifconfig [bla .. bla ..] multicast
> > route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
>
> I'm using Linux Red Had 2.0.31
> Do you have any idea about what I missed !?
> Thanx a lot.

So what does your ifconfig report? Mine reports flags as follows:
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1

Is your kernel multicast-enabled? If not, you will have to rebuild it:
CONFIG_IP_MULTICAST=y

If your machine has 2 network cards and you want mcast groups on
either side, you should also set:
CONFIG_IP_MROUTE=y

...but I could never get this to work properly, at least on 2.0.30 :-(
(Although I posted to this group at the time, I got no response. AFAIR
my problem was that packets originating at the host were only sent out
on one side although both sides contained group members. Forwarding
between the sides worked fine.)

--Steve
Stephen Crane, Dept of Computing, Imperial College of Science, Technology and
Medicine, 180 Queen's Gate, London sw7 2bz, UK:jsc@{doc.ic.ac.uk, icdoc.uucp}


0 new messages