LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   MULTICAST address and port, socket listen only on port? (https://www.linuxquestions.org/questions/linux-networking-3/multicast-address-and-port-socket-listen-only-on-port-704192/)

jf.argentino 02-12-2009 10:08 AM

MULTICAST address and port, socket listen only on port?
 
Hello

I've notice something that I found strange, so if somebody could explain it to me it would be wonderful.

I make an application on GNU/Linux which listening on a MULTICAST stream, so I open my unconnected socket, bind it on a MULTICAST address and a port, join the multicast group with the "setsockopt (IP_ADD_MEMBERSHIP)", then I receive datagram on my socket.

Now I've two different instances of the same application that run with their own MULTICAST address and port. And what I found strange is that, after a misconfiguration, I switch the ports, for example:
Emitting on 225.0.0.1/23451 and 225.0.0.2/23452
Receiving on 225.0.0.1/23452 and 225.0.0.2/23451
And my receiving part doesn't care about the MULTICAST address, it looks like the socket is listening on the port number only! I mean that the receiver [225.0.0.1/23452] take its datagrams from emitter [225.0.0.2/23452] and vice-versa!

I'll try other tests to investigate it but does anybody can explain that thing to me?

Regards.

baldy3105 02-14-2009 01:43 PM

You have bug is about the only thing I can think of. A multicast client should only accept multicast packets from groups that it has joined. Any other packets should be dropped.

jf.argentino 03-09-2009 12:42 PM

OK, it looks like I have to join the MULTICAST group with setsockopt (IP_ADD_MEMBERSHIP) _BEFORE_ bind'ing my socket on the port!
Could anybody confirm that.
Thanks


All times are GMT -5. The time now is 06:30 PM.