UdpClient.DropMulticastGroup UdpClient.DropMulticastGroup UdpClient.DropMulticastGroup UdpClient.DropMulticastGroup Method

定義

保留多點傳送 (Multicast) 群組。Leaves a multicast group.

多載

DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32)

保留多點傳送 (Multicast) 群組。Leaves a multicast group.

DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress)

保留多點傳送 (Multicast) 群組。Leaves a multicast group.

DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32) DropMulticastGroup(IPAddress, Int32)

保留多點傳送 (Multicast) 群組。Leaves a multicast group.

public:
 void DropMulticastGroup(System::Net::IPAddress ^ multicastAddr, int ifindex);
public void DropMulticastGroup (System.Net.IPAddress multicastAddr, int ifindex);
member this.DropMulticastGroup : System.Net.IPAddress * int -> unit
Public Sub DropMulticastGroup (multicastAddr As IPAddress, ifindex As Integer)

參數

multicastAddr
IPAddress IPAddress IPAddress IPAddress

要保留的多點傳送群組其 IPAddressThe IPAddress of the multicast group to leave.

ifindex
Int32 Int32 Int32 Int32

要保留之多點傳送群組的本機位址。The local address of the multicast group to leave.

例外狀況

存取通訊端時發生錯誤。An error occurred when accessing the socket.

IP 位址與 AddressFamily 值不相容,這個值定義著通訊端的定址配置。The IP address is not compatible with the AddressFamily value that defines the addressing scheme of the socket.

範例

下列程式碼範例示範如何藉由提供多播位址來卸載多播群組。The following code example demonstrates how to drop a multicast group by providing a multicast address.

// Send data to ClientTarget.
Console::WriteLine( "\nThe ClientOriginator sent:\n" );
Send::OriginatorSendData( clientOriginator, m_ClientTargetdest );

// Receive data from ClientTarget
Ret = Receive::ReceiveUntilStop( clientOriginator );

// Stop the ClientTarget thread
m_t->Abort();

// Abandon the multicast group.
clientOriginator->DropMulticastGroup( m_GrpAddr );


// Send data to ClientTarget.
Console.WriteLine("\nThe ClientOriginator sent:\n");
Send.OriginatorSendData(clientOriginator, m_ClientTargetdest);

// Receive data from ClientTarget
Ret = Receive.ReceiveUntilStop(clientOriginator);

// Stop the ClientTarget thread
m_t.Abort();

// Abandon the multicast group.
clientOriginator.DropMulticastGroup(m_GrpAddr);

' Send data to ClientTarget.
Console.WriteLine(ControlChars.Lf + "The ClientOriginator sent:" + ControlChars.Lf)
Send.OriginatorSendData(clientOriginator, m_ClientTargetdest)

' Receive data from ClientTarget
Ret = Receive.ReceiveUntilStop(clientOriginator)

' Stop the ClientTarget thread
m_t.Abort()

' Abandon the multicast group.
clientOriginator.DropMulticastGroup(m_GrpAddr)

備註

方法會UdpClient從指定IPAddress的所識別的多播群組中收回。 DropMulticastGroupThe DropMulticastGroup method withdraws the UdpClient from the multicast group identified by the specified IPAddress. 呼叫DropMulticastGroup方法之後,基礎Socket會將網際網路群組管理通訊協定(IGMP)封包傳送至路由器,並從多播群組移除路由器。After calling the DropMulticastGroup method, the underlying Socket sends an Internet Group Management Protocol (IGMP) packet to the router, removing the router from the multicast group. 從群組中收回之後,它將無法再接收傳送到該群組的資料包。 UdpClientAfter a UdpClient withdraws from the group, it will no longer be able to receive datagrams sent to that group.

注意

如果您收到SocketException,請SocketException.ErrorCode使用屬性來取得特定的錯誤碼。If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. 取得此程式碼之後,您可以參考Windows socket 第2版 API 錯誤碼檔,以取得錯誤的詳細描述。After you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.

另請參閱

DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress) DropMulticastGroup(IPAddress)

保留多點傳送 (Multicast) 群組。Leaves a multicast group.

public:
 void DropMulticastGroup(System::Net::IPAddress ^ multicastAddr);
public void DropMulticastGroup (System.Net.IPAddress multicastAddr);
member this.DropMulticastGroup : System.Net.IPAddress -> unit
Public Sub DropMulticastGroup (multicastAddr As IPAddress)

參數

multicastAddr
IPAddress IPAddress IPAddress IPAddress

要保留的多點傳送群組其 IPAddressThe IPAddress of the multicast group to leave.

例外狀況

存取通訊端時發生錯誤。An error occurred when accessing the socket.

IP 位址與 AddressFamily 值不相容,這個值定義著通訊端的定址配置。The IP address is not compatible with the AddressFamily value that defines the addressing scheme of the socket.

範例

下列範例示範如何藉由提供多播位址來卸載多播群組。The following example demonstrates how to drop a multicast group by providing a multicast address.

// Send data to ClientTarget.
Console::WriteLine( "\nThe ClientOriginator sent:\n" );
Send::OriginatorSendData( clientOriginator, m_ClientTargetdest );

// Receive data from ClientTarget
Ret = Receive::ReceiveUntilStop( clientOriginator );

// Stop the ClientTarget thread
m_t->Abort();

// Abandon the multicast group.
clientOriginator->DropMulticastGroup( m_GrpAddr );


// Send data to ClientTarget.
Console.WriteLine("\nThe ClientOriginator sent:\n");
Send.OriginatorSendData(clientOriginator, m_ClientTargetdest);

// Receive data from ClientTarget
Ret = Receive.ReceiveUntilStop(clientOriginator);

// Stop the ClientTarget thread
m_t.Abort();

// Abandon the multicast group.
clientOriginator.DropMulticastGroup(m_GrpAddr);

' Send data to ClientTarget.
Console.WriteLine(ControlChars.Lf + "The ClientOriginator sent:" + ControlChars.Lf)
Send.OriginatorSendData(clientOriginator, m_ClientTargetdest)

' Receive data from ClientTarget
Ret = Receive.ReceiveUntilStop(clientOriginator)

' Stop the ClientTarget thread
m_t.Abort()

' Abandon the multicast group.
clientOriginator.DropMulticastGroup(m_GrpAddr)

備註

方法會UdpClient從指定IPAddress的所識別的多播群組中收回。 DropMulticastGroupThe DropMulticastGroup method withdraws the UdpClient from the multicast group identified by the specified IPAddress. 呼叫DropMulticastGroup方法之後,基礎Socket會將網際網路群組管理通訊協定(IGMP)封包傳送至路由器,並從多播群組移除路由器。After calling the DropMulticastGroup method, the underlying Socket sends an Internet Group Management Protocol (IGMP) packet to the router, removing the router from the multicast group. 從群組中收回之後,它將無法再接收傳送到該群組的資料包。 UdpClientAfter a UdpClient withdraws from the group, it will no longer be able to receive datagrams sent to that group.

注意

如果您收到SocketException,請使用SocketException.ErrorCode來取得特定的錯誤碼。If you receive a SocketException, use SocketException.ErrorCode to obtain the specific error code. 取得此程式碼之後,您可以參考Windows socket 第2版 API 錯誤碼檔,以取得錯誤的詳細描述。Once you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.

另請參閱

適用於