On 01/05/2020 14:19, Chris Hegarty wrote:
:

Has any consideration been given to restricting the set of allowable
integer values that may be set for this option - say, to none? Which
would then lead to an IllegalArgumentException if `setOption` is
invoked in an attempt to set this socket option - since no given value
is allowable.

This is a good topic and I think you are right that this is the first time that an option will be specified as "read-only". There are corner cases with a few of the existing socket options are awkward. SO_FLOW_SLA comes to mind as one that doesn't have a default value so can't be read until it is set. The SO_BROADCAST system option can't be enabled on some operating systems without special operating system permissions.

I think the choices for the exception are UOE or IOException. I don't see IAE as an option because it implies that there is at least one value that is valid for the parameter and this isn't the case here. If UOE is used then it would require tweaking the javadoc a bit to allow it be thrown when the option is not writable. IOException might be the least worst option as it's already thrown in several cases where socket options can't be changed (for various reasons).

-Alan.

Reply via email to