UdpClient.Close 方法

定義

關閉 UDP 連接。

public:
 void Close();
public void Close ();
member this.Close : unit -> unit
Public Sub Close ()

例外狀況

存取通訊端時發生錯誤。

範例

下列範例示範藉由呼叫 Close 方法來關閉 UdpClient

// Closes the UDP client by calling the public method Close().
udpClient->Close();
// Closes the UDP client by calling the public method Close().
udpClient.Close();
' Closes the UDP client by calling the public method Close().
udpClient.Close()

備註

Close 停用基礎 Socket ,並釋放與 相關聯的 UdpClient 所有 Managed 和 Unmanaged 資源。

注意

如果您收到 SocketException ,請使用 SocketException.ErrorCode 來取得特定的錯誤碼。 取得此程式碼之後,您可以參考 Windows Sockets 第 2 版 API 錯誤碼 檔,以取得錯誤的詳細描述。

適用於

另請參閱