ISocketOptions.GetOption(Int32) Method

Definition

Fetch the value of an option.

[Android.Runtime.Register("getOption", "(I)Ljava/lang/Object;", "GetGetOption_IHandler:Java.Net.ISocketOptionsInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public Java.Lang.Object? GetOption (int optID);
[<Android.Runtime.Register("getOption", "(I)Ljava/lang/Object;", "GetGetOption_IHandler:Java.Net.ISocketOptionsInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member GetOption : int -> Java.Lang.Object

Parameters

optID
Int32

an int identifying the option to fetch

Returns

the value of the option

Attributes

Exceptions

if an error occurs reading the option value.

Remarks

Fetch the value of an option. Binary options will return java.lang.Boolean.TRUE if enabled, java.lang.Boolean.FALSE if disabled, e.g.: <BR>

SocketImpl s;
            ...
            Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY));
            if (noDelay.booleanValue()) {
                // true if TCP_NODELAY is enabled...
            ...
            }

For options that take a particular type as a parameter, getOption(int) will return the parameter's value, else it will return java.lang.Boolean.FALSE:

Object o = s.getOption(SO_LINGER);
            if (o instanceof Integer) {
                System.out.print("Linger time is " + ((Integer)o).intValue());
            } else {
              // the true type of o is java.lang.Boolean.FALSE;
            }

Java documentation for java.net.SocketOptions.getOption(int).

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