UdpClient Constructor (Int32)
Initializes a new instance of the UdpClient class and binds it to the local port number provided.
Assembly: System (in System.dll)
This constructor creates an underlying Socket and binds it to the port number from which you intend to communicate. Use this constructor if you are only interested in setting the local port number. The underlying service provider will assign the local IP address. If you pass 0 to the constructor, the underlying service provider will assign a port number. If this constructor is used, the UdpClient instance is set with an address family of IPv4 that cannot be changed or overwritten by a connect method call with an IPv6 target.
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 in MSDN for a detailed description of the error.
This constructor works only with IPv4 address types.
The following example demonstrates using a local port number to create an instance of the UdpClient class.
Available since 1.1