UdpClient.Close UdpClient.Close UdpClient.Close UdpClient.Close Method

定義

關閉 UDP 連接。Closes the UDP connection.

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

例外狀況

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

範例

下列範例將示範如何藉UdpClientClose呼叫方法來關閉。The following example demonstrates closing a UdpClient by calling the Close method.

// 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()

備註

會停用基礎Socket , 並釋放與關聯的UdpClient所有受控和非受控資源。 CloseThe Close disables the underlying Socket and releases all managed and unmanaged resources associated with the UdpClient.

注意

如果您收到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.

適用於

另請參閱