[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Multicast Problem!!!



On Mon, Feb 19, 2001 at 04:40:02PM +0530, vrd_boss@indya.com wrote:
> Hello, 
>       I don't know how to join to a multicast 
> group in Linux.
>       My ethernet card is multicast enabled.
>      (from the ifconfig)
>       Could You tell me how to join to a 
> multicast group.
>       Please help me.

Do you have some specific multicast group in mind?  All the applications
that utilize multicast can do it by themselves already, it's only a few
lines of code.  

Or do you want to join a multicast group in your own program?  If so, here
the few lines of code I mentioned.  It's totally untested, lacks all error
checking and such, but should give you the idea.

    struct ip_mreq imr;
    int sock;
    sock = socket(AF_INET, SOCK_DGRAM, 0);
    memset(&imr, 0, sizeof(imr));
    inet_aton("224.0.0.1", &imr.imr_multiaddr);
    setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imr, sizeof(imr));


However, if your upstream router does not support multicast routing,
joining a multicast group won't do you much good since you will be limited
to the multicast traffic within your own LAN.


-- 
Tommi Komulainen                                 Tommi.Komulainen@iki.fi
GPG 1024D/68388EE6    6FD6 DD79 EB38 BF6F 3533  09C0 04A8 9871 6838 8EE6

Attachment: pgprglVObjiLQ.pgp
Description: PGP signature


Reply to: