This documentation is archived and is not being maintained.

TcpListener.ExclusiveAddressUse Property

Gets or sets a Boolean value that specifies whether the TcpListener allows only one underlying socket to listen to a specific port.

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

'Declaration
Public Property ExclusiveAddressUse As Boolean
'Usage
Dim instance As TcpListener 
Dim value As Boolean 

value = instance.ExclusiveAddressUse

instance.ExclusiveAddressUse = value

Property Value

Type: System.Boolean
true if the TcpListener allows only one TcpListener to listen to 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
InvalidOperationException

The TcpListener has been started. Call the Stop method and then set the ExclusiveAddressUse property.

SocketException

An error occurred when attempting to access the underlying socket.

ObjectDisposedException

The underlying Socket has been closed.

By default, multiple listeners can listen to a specific port. However, only one of the listeners can perform operations on the network traffic sent to the port. If more than one listener attempts to bind to a particular port, then the one with the more specific IP address handles the network traffic sent to that port. You can use the ExclusiveAddressUse property to prevent multiple listeners from listening to a specific port.

Set this property before calling Start, or call the Stop method and then set this 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 gets and sets the ExclusiveAddressUse property.

Public Shared Sub GetSetExclusiveAddressUse(t As TcpListener)
   ' Set Exclusive Address Use for the underlying socket.
   t.ExclusiveAddressUse = True
   Console.WriteLine("ExclusiveAddressUse value is {0}", t.ExclusiveAddressUse)
End Sub 'GetSetExclusiveAddressUse
static void GetSetExclusiveAddressUse(TcpListener* t)
{
    // Set Exclusive Address Use for the underlying socket.
    t->ExclusiveAddressUse = true;
    Console::WriteLine(S"ExclusiveAddressUse value is {0}",
        __box(t->ExclusiveAddressUse));
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: