简体   繁体   English

从不同端口接收组播

[英]Receiving Multicast From Different Ports

Basically I have an application that creates say 5 multicast sockets on the same interface and within the same application, each socket binds to a different multicast IP address/port. 基本上我有一个应用程序在同一个接口和同一个应用程序中创建5个多播套接字,每个套接字绑定到不同的多播IP地址/端口。 When any one of those sockets sends a message, the other 4 sockets within the application end up reading that message. 当这些套接字中的任何一个发送消息时,应用程序中的其他4个套接字最终会读取该消息。 Is this normal behavior? 这是正常的行为吗?

This is happening in Ubuntu 11.10 using boost.asio and gcc 4.6. 这是在Ubuntu 11.10中使用boost.asio和gcc 4.6进行的。

这在某些操作系统中是正常的;-)您可以使用setsockopt()和IP_MULTICAST_LOOP选项将其关闭。

Sounds strange to me. 听起来很奇怪。 If you are using UDP, then you should only receive messages associated with the port number of the UDP socket. 如果您使用的是UDP,则只应接收与UDP套接字的端口号关联的消息。 Of course, if you using multicast at the IP level, then the port number would not matter. 当然,如果您在IP级别使用多播,那么端口号无关紧要。

It is quite true (as per EJP) that loopback will cause programs to receive their own messages if loopback isn't disabled. 完全正确(根据EJP),如果未禁用环回,则环回将导致程序接收自己的消息。 However, the UDP port numbers still apply. 但是,UDP端口号仍然适用。 A multicast UDP message sent to port x, should not be received by a socket listening for port y. 发送到端口x的多播UDP消息不应由侦听端口y的套接字接收。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM