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.
Assembly: System (in System.dll)
Property Value
Type: System::Booleantrue 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 | Condition |
|---|---|
| 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.
The default value for this property is true for Service Pack 2 and later.
The default value for this property is true.
The application must run as Administrator to use this property.
For Service Pack 1, the application must run as Administrator to use this property.
The following code example gets and sets the ExclusiveAddressUse property.
Available since 2.0