다음을 통해 공유


ServerSocket.ReuseAddress Property

Definition

Tests if SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled. -or- Enable/disable the SocketOptions#SO_REUSEADDR SO_REUSEADDR socket option.

public virtual bool ReuseAddress { [Android.Runtime.Register("getReuseAddress", "()Z", "GetGetReuseAddressHandler")] get; [Android.Runtime.Register("setReuseAddress", "(Z)V", "GetSetReuseAddress_ZHandler")] set; }
[<get: Android.Runtime.Register("getReuseAddress", "()Z", "GetGetReuseAddressHandler")>]
[<set: Android.Runtime.Register("setReuseAddress", "(Z)V", "GetSetReuseAddress_ZHandler")>]
member this.ReuseAddress : bool with get, set

Property Value

a boolean indicating whether or not SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled.

Attributes

Exceptions

if an error occurs while reading the option value.

if an error occurs while setting the option value.

Remarks

Property getter documentation:

Tests if SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled.

Added in 1.4.

Java documentation for java.net.ServerSocket.getReuseAddress().

Property setter documentation:

Enable/disable the SocketOptions#SO_REUSEADDR SO_REUSEADDR socket option.

When a TCP connection is closed the connection may remain in a timeout state for a period of time after the connection is closed (typically known as the TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port.

Enabling SocketOptions#SO_REUSEADDR SO_REUSEADDR prior to binding the socket using #bind(SocketAddress) allows the socket to be bound even though a previous connection is in a timeout state.

When a ServerSocket is created the initial setting of SocketOptions#SO_REUSEADDR SO_REUSEADDR is not defined. Applications can use #getReuseAddress() to determine the initial setting of SocketOptions#SO_REUSEADDR SO_REUSEADDR.

The behaviour when SocketOptions#SO_REUSEADDR SO_REUSEADDR is enabled or disabled after a socket is bound (See #isBound()) is not defined.

Added in 1.4.

Java documentation for java.net.ServerSocket.setReuseAddress(boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to