receiving multicast packets

Let's say my application wants to receive two different multicast streams.  One is broadcast to 224.2.2.100:9020 and one to 224.3.3.300:9020.

I have two different sockets (on different threads) which go through the following process:
   socket()
   setsockopt() // to allow binding on the same port
   bind() // bind to port 9020
   setsockopt() // to join the multicast group for the multicast address we want to listen to
   recvfrom() // call this in a loop to get our multicast packets

The problem I'm having is that each socket is receiving packets from BOTH multicast groups!  Shouldn't the socket only receive packets from the multicast address that is joined to via setsockopt?

Also it should be noted that if the two multicast streams I'm receiving are on different ports, then this problem doesn't exist.
LVL 5
lwinkenbAsked:
Who is Participating?
 
ee_ai_constructCommented:
Closed, 500 points refunded.
ee_ai_construct
Community Support Moderator
replacement part #xm34
0
 
leisnerCommented:
can you post the snippet of the sequence so I can look at the docs......I haven't written code listening to
multicast in a long time...

Just wanna check to see what you're doing...

If you have a test program, that would be even better!!

 
0
 
lwinkenbAuthor Commented:
I ended up figuring out the problem.  As it turns out, I had to bind to the multicast address in order to only receive those multicast packets.  What threw me off was that all the example code I saw always bound to INADDR_ANY.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.