UdpClient.ExclusiveAddressUse Property

Gets or sets a Boolean value that specifies whether the UdpClient allows only one client to use a port.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

public bool ExclusiveAddressUse { get; set; }

Property Value

Type: System.Boolean
true if the UdpClient allows only one client to use a specific port; otherwise, false. The default is true for Windows Server 2003 and Windows XP Service Pack 2 and later, and false for all other versions.

ExceptionCondition
SocketException

An error occurred when attempting to access the underlying socket.

ObjectDisposedException

The underlying Socket has been closed.

By default, multiple clients can use a specific port; however, only one of the clients can perform operations on the network traffic sent to the port. You can use the ExclusiveAddressUse property to prevent multiple clients from using a specific port.

This property must be set before the underlying socket is bound to a client port. If you call UdpClient.UdpClient(Int32), UdpClient.UdpClient(Int32, AddressFamily), UdpClient.UdpClient(IPEndPoint), or UdpClient.UdpClient(String, Int32), the client port is bound as a side effect of the constructor, and you cannot subsequently set the ExclusiveAddressUse property

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: The default value for this property is true for Service Pack 2 and later.

Windows Server 2003 Platform Note: The default value for this property is true.

Windows 2000 Platform Note: The application must run as Administrator to use this property.

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: For Service Pack 1, the application must run as Administrator to use this property.

The following code example creates a UdpClient, and gets and sets the ExclusiveAddressUse property.


public static void GetSetExclusiveAddressUse(UdpClient u)
{
    // Don't allow another client to bind to this port.
    u.ExclusiveAddressUse = true;
    Console.WriteLine("ExclusiveAddressUse value is {0}",
        u.ExclusiveAddressUse);
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft