Enable/disable the option specified by
optID. If the option is to be enabled, and it takes an option-specific "value", this is passed in
value. The actual type of value is option-specific, and it is an error to pass something that isn't of the expected type:
SocketImpl s;
...
s.setOption(SO_LINGER, new Integer(10));
// OK - set SO_LINGER w/ timeout of 10 sec.
s.setOption(SO_LINGER, new Double(10));
// ERROR - expects java.lang.Integer
If the requested option is binary, it can be set using this method by a java.lang.Boolean:
s.setOption(TCP_NODELAY, Boolean.TRUE);
// OK - enables TCP_NODELAY, a binary option
Any option can be disabled using this method with a Boolean.FALSE:
s.setOption(TCP_NODELAY, Boolean.FALSE);
// OK - disables TCP_NODELAY
s.setOption(SO_LINGER, Boolean.FALSE);
// OK - disables SO_LINGER
For an option that has a notion of on and off, and requires a non-boolean parameter, setting its value to anything other than
Boolean.FALSE implicitly enables it.
Throws SocketException if the option is unrecognized, the socket is closed, or some low-level error occurred