Socket.MulticastLoopback Socket.MulticastLoopback Socket.MulticastLoopback Socket.MulticastLoopback Property

定义

获取或设置一个值,该值指定传出的多路广播数据包是否传递到发送应用程序。Gets or sets a value that specifies whether outgoing multicast packets are delivered to the sending application.

public:
 property bool MulticastLoopback { bool get(); void set(bool value); };
public bool MulticastLoopback { get; set; }
member this.MulticastLoopback : bool with get, set
Public Property MulticastLoopback As Boolean

属性值

如果 Socket 接收传出的多路广播数据包,则为 true;否则为 falsetrue if the Socket receives outgoing multicast packets; otherwise, false.

异常

尝试访问套接字时出错。An error occurred when attempting to access the socket.

示例

下面的代码示例演示如何将MulticastLoopback属性。The following code example demonstrates the use of the MulticastLoopback property.

static void ConfigureUdpSocket(Socket^ udpSocket)
{

    // Set the Don't Fragment flag.
    udpSocket->DontFragment = true;
     
    // Enable broadcast.
    udpSocket->EnableBroadcast = true;
     
    // Disable multicast loopback.
    udpSocket->MulticastLoopback = false;
    Console::WriteLine("Udp Socket configured:");
    Console::WriteLine("  DontFragment {0}", 
        udpSocket->DontFragment);
    Console::WriteLine("  EnableBroadcast {0}", 
        udpSocket->EnableBroadcast);
    Console::WriteLine("  MulticastLoopback {0}", 
        udpSocket->MulticastLoopback);
}
      static void ConfigureUdpSocket(Socket udpSocket)
{
	// set the Don't Fragment flag.
	udpSocket.DontFragment = true;
	// Enable broadcast.
	udpSocket.EnableBroadcast = true;

	// Disable multicast loopback.
	udpSocket.MulticastLoopback = false;

	Console.WriteLine("Udp Socket configured:");
	Console.WriteLine("  DontFragment {0}", 
                                              udpSocket.DontFragment);
	Console.WriteLine("  EnableBroadcast {0}", 
                                              udpSocket.EnableBroadcast);
	Console.WriteLine("  MulticastLoopback {0}", 
                                              udpSocket.MulticastLoopback);
}

注解

多播是在 Internet 上的多对多通信的可缩放方法。Multicast is a scalable method for many-to-many communication on the Internet. 处理订阅的多播地址;然后,可由其他每个订阅的多播地址的过程接收已订阅进程发送任何数据包。A process subscribes to a multicast address; then, any packets sent by a subscribed process are received by every other process subscribed to the multicast address.

传输控制协议 (TCP) 套接字上设置此属性不会影响。Setting this property on a Transmission Control Protocol (TCP) socket will have no effect.

适用于