59 * // ERROR - expects java.lang.Integer |
59 * // ERROR - expects java.lang.Integer |
60 *</PRE> |
60 *</PRE> |
61 * If the requested option is binary, it can be set using this method by |
61 * If the requested option is binary, it can be set using this method by |
62 * a java.lang.Boolean: |
62 * a java.lang.Boolean: |
63 * <BR><PRE> |
63 * <BR><PRE> |
64 * s.setOption(TCP_NODELAY, new Boolean(true)); |
64 * s.setOption(TCP_NODELAY, Boolean.TRUE); |
65 * // OK - enables TCP_NODELAY, a binary option |
65 * // OK - enables TCP_NODELAY, a binary option |
66 * </PRE> |
66 * </PRE> |
67 * <BR> |
67 * <BR> |
68 * Any option can be disabled using this method with a Boolean(false): |
68 * Any option can be disabled using this method with a Boolean.FALSE: |
69 * <BR><PRE> |
69 * <BR><PRE> |
70 * s.setOption(TCP_NODELAY, new Boolean(false)); |
70 * s.setOption(TCP_NODELAY, Boolean.FALSE); |
71 * // OK - disables TCP_NODELAY |
71 * // OK - disables TCP_NODELAY |
72 * s.setOption(SO_LINGER, new Boolean(false)); |
72 * s.setOption(SO_LINGER, Boolean.FALSE); |
73 * // OK - disables SO_LINGER |
73 * // OK - disables SO_LINGER |
74 * </PRE> |
74 * </PRE> |
75 * <BR> |
75 * <BR> |
76 * For an option that has a notion of on and off, and requires |
76 * For an option that has a notion of on and off, and requires |
77 * a non-boolean parameter, setting its value to anything other than |
77 * a non-boolean parameter, setting its value to anything other than |
78 * <I>Boolean(false)</I> implicitly enables it. |
78 * <I>Boolean.FALSE</I> implicitly enables it. |
79 * <BR> |
79 * <BR> |
80 * Throws SocketException if the option is unrecognized, |
80 * Throws SocketException if the option is unrecognized, |
81 * the socket is closed, or some low-level error occurred |
81 * the socket is closed, or some low-level error occurred |
82 * <BR> |
82 * <BR> |
83 * @param optID identifies the option |
83 * @param optID identifies the option |
89 public void |
89 public void |
90 setOption(int optID, Object value) throws SocketException; |
90 setOption(int optID, Object value) throws SocketException; |
91 |
91 |
92 /** |
92 /** |
93 * Fetch the value of an option. |
93 * Fetch the value of an option. |
94 * Binary options will return java.lang.Boolean(true) |
94 * Binary options will return java.lang.Boolean.TRUE |
95 * if enabled, java.lang.Boolean(false) if disabled, e.g.: |
95 * if enabled, java.lang.Boolean.FALSE if disabled, e.g.: |
96 * <BR><PRE> |
96 * <BR><PRE> |
97 * SocketImpl s; |
97 * SocketImpl s; |
98 * ... |
98 * ... |
99 * Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); |
99 * Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); |
100 * if (noDelay.booleanValue()) { |
100 * if (noDelay.booleanValue()) { |
103 * } |
103 * } |
104 * </PRE> |
104 * </PRE> |
105 * <P> |
105 * <P> |
106 * For options that take a particular type as a parameter, |
106 * For options that take a particular type as a parameter, |
107 * getOption(int) will return the parameter's value, else |
107 * getOption(int) will return the parameter's value, else |
108 * it will return java.lang.Boolean(false): |
108 * it will return java.lang.Boolean.FALSE: |
109 * <PRE> |
109 * <PRE> |
110 * Object o = s.getOption(SO_LINGER); |
110 * Object o = s.getOption(SO_LINGER); |
111 * if (o instanceof Integer) { |
111 * if (o instanceof Integer) { |
112 * System.out.print("Linger time is " + ((Integer)o).intValue()); |
112 * System.out.print("Linger time is " + ((Integer)o).intValue()); |
113 * } else { |
113 * } else { |
114 * // the true type of o is java.lang.Boolean(false); |
114 * // the true type of o is java.lang.Boolean.FALSE; |
115 * } |
115 * } |
116 * </PRE> |
116 * </PRE> |
117 * |
117 * |
118 * @param optID an {@code int} identifying the option to fetch |
118 * @param optID an {@code int} identifying the option to fetch |
119 * @return the value of the option |
119 * @return the value of the option |