ReuseAddress Property  
 

Set or return if the local address can be reused by the server.

Syntax

object.ReuseAddress [= { True | False } ]

Remarks

The ReuseAddress property is used to determine if the local address and port number can be reused when starting a new instance of the server. Setting this property to True enables a server application to listen for connections using the specified address and port number even if they were in use recently. This is typically used to enable the server to close the listening socket and immediately reopen it without getting an error that the address is in use.

When a listening socket closed, the socket will normally go into a TIME-WAIT state where the local address and port number cannot be immediately reused. A consequence of this is that calling the Stop method immediately followed by the Start method using the same address and port number values may result in an error indicating that the specified address is already in use. By setting this property to True, that error is avoided and the listening socket can be created immediately without waiting for the TIME-WAIT period to elapse. Note that calling the Restart method allows the local address and port number to be reused, regardless of this property value.

If you wish to determine if a local port number is already in use by another application, set this property to false and attempt to start a server using that port number. If another application is already using that port number, an error will be generated indicating that the address is in use and the server could not be started.

Data Type

Boolean

See Also

ServerAddress Property, ServerPort Property, Restart Method, Start Method, Stop Method