mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Shantanu.Gogate" <shantanu.gogate@wibhu.com>
To: linux-kernel@vger.kernel.org
Subject: problems with using multicast
Date: 12 May 2003 12:48:13 +0530	[thread overview]
Message-ID: <1052723893.1807.54.camel@Jughead.Wibhu> (raw)

Hi,
    I am trying to use multicast in an application which. I am running
kernel 2.4.19.I have interfaces lo, and eth0 on bootup.  Here is what I
am trying to do...

When i try to create a socket which becomes a member of a multicast
group by specifying the grp address and using INADDR_ANY as the
interface to use, i am able to receive packets sent out the multicast
group. However if i specifically bind it to the address of eth0 and then
try to receive packets...i am not getting any....The only other
interfaces i have are lo. I cant explain why it is working when i use
INADDR_ANY and does not receive packets when i use the specific address
of the device....

the code for this socket init looks as follows ...i have removed error
handling for readability right now
--------------
         server_socket = socket(AF_INET, SOCK_DGRAM,0);
  
         memset(&saddr,0,sizeof(struct sockaddr_in));
         saddr.sin_family = AF_INET;
         saddr.sin_addr.s_addr = htonl(INADDR_ANY);
         saddr.sin_port = port;

        bind(server_socket, (struct sockaddr *) &saddr, sizeof(saddr);
        
on=1;
setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(on));

        mreq.imr_multiaddr.s_addr = mcast_addr;
        mreq.imr_interface.s_addr = htonl(INADDR_ANY);
       
setsockopt(server_socket,SOL_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq))

ttl = 1;
setsockopt(server_socket, IPPROTO_IP, IP_MULTICAST_TTL,&ttl,sizeof(ttl))

loop = 0;
setsockoptserver_socket,IPPROTO_IP,IP_MULTICAST_LOOP,&loop,sizeof(loop))

return server_socket;
----------------------------------      
if i replace INADDR_ANY with the actual interface address which i get
using ioctl, then i cant receive any packets... However when i see the
dump from tcpdump i can see the packets coming in, but for some reason
they are not reaching the socket which had become a member. I can also
see that the group membership was added if i do netstat -g


I would appreciate any help.

Thanks and regards,
Shantanu.


                 reply	other threads:[~2003-05-12  7:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1052723893.1807.54.camel@Jughead.Wibhu \
    --to=shantanu.gogate@wibhu.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®