ExclusiveAddressUse Property
Collapse the table of content
Expand the table of content

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)

public bool ExclusiveAddressUse { get; set; }
/** @property */
public boolean get_ExclusiveAddressUse ()

/** @property */
public void set_ExclusiveAddressUse (boolean value)

public function get ExclusiveAddressUse () : boolean

public function set ExclusiveAddressUse (value : boolean)

Not applicable.

Property Value

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.

Exception typeCondition

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 static void GetSetExclusiveAddressUse(TcpListener t)
{
    // Set Exclusive Address Use for the underlying socket.
    t.ExclusiveAddressUse = true;
    Console.WriteLine("ExclusiveAddressUse value is {0}",
        t.ExclusiveAddressUse);
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2016 Microsoft