DatagramSocket.ReuseAddress Property

Definition

Tests if SO_REUSEADDR is enabled. -or- Enable/disable the 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 SO_REUSEADDR is enabled.

Attributes

Exceptions

if the socket is closed or the option is invalid.

if the socket is closed or the option could not be set.

Remarks

Property getter documentation:

Tests if SO_REUSEADDR is enabled.

Added in 1.4.

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

Property setter documentation:

Enable/disable the SO_REUSEADDR socket option.

For UDP sockets it may be necessary to bind more than one socket to the same socket address. This is typically for the purpose of receiving multicast packets (See java.net.MulticastSocket). The SO_REUSEADDR socket option allows multiple sockets to be bound to the same socket address if the SO_REUSEADDR socket option is enabled prior to binding the socket using #bind(SocketAddress).

Note: This functionality is not supported by all existing platforms, so it is implementation specific whether this option will be ignored or not. However, if it is not supported then #getReuseAddress() will always return false.

When a DatagramSocket is created the initial setting of SO_REUSEADDR is disabled.

The behaviour when 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.DatagramSocket.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