UdpClient.Close Method

Definition

Closes the UDP connection.

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

Exceptions

An error occurred when accessing the socket.

Examples

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

Remarks

The Close disables the underlying Socket and releases all managed and unmanaged resources associated with the UdpClient.

Note

If you receive a SocketException, use SocketException.ErrorCode to obtain the specific error code. 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.

Applies to

See also