UDP通信实例(3)--组播回环

按照https://blog.csdn.net/lucky_greenegg/article/details/84938565 的说法,结合https://docs.microsoft.com/zh-cn/windows/desktop/WinSock/ip-multicast-2 的描述,

The Winsock version of the IP_MULTICAST_LOOP option is semantically different than the UNIX version of the IP_MULTICAST_LOOP option:

  • In Winsock, the IP_MULTICAST_LOOP option applies only to the receive path.
  • In the UNIX version, the IP_MULTICAST_LOOP option applies to the send path.

For example, applications ON and OFF (which are easier to track than X and Y) join the same group on the same interface; application ON sets the IP_MULTICAST_LOOP option on, application OFF sets the IP_MULTICAST_LOOP option off. If ON and OFF are Winsock applications, OFF can send to ON, but ON cannot sent to OFF. In contrast, if ON and OFF are UNIX applications, ON can send to OFF, but OFF cannot send to ON.

我把回环组播的理解画出来讲解下:

对于unix系统,实现阻断的办法是阻断发送:

UDP通信实例(3)--组播回环_第1张图片

对于windows,实现阻断靠的是阻断接收:

UDP通信实例(3)--组播回环_第2张图片

假如在同一台计算机上有两个应用程序,并且加入了同一个组播。这两个程序,一个允许回环,一个阻断回环,则会有如下现象:

windows下,允许方不能发向阻断方,但阻断方可以发向允许方;

linux下,允许方可以发向阻断方,但阻断方不能发向允许方。

 

 

你可能感兴趣的:(UDP通信实例(3)--组播回环)