< prev index next >

src/java.base/share/classes/java/net/SocketOptions.java

Print this page

        

*** 59,83 **** * // ERROR - expects java.lang.Integer *</PRE> * If the requested option is binary, it can be set using this method by * a java.lang.Boolean: * <BR><PRE> ! * s.setOption(TCP_NODELAY, new Boolean(true)); * // OK - enables TCP_NODELAY, a binary option * </PRE> * <BR> ! * Any option can be disabled using this method with a Boolean(false): * <BR><PRE> ! * s.setOption(TCP_NODELAY, new Boolean(false)); * // OK - disables TCP_NODELAY ! * s.setOption(SO_LINGER, new Boolean(false)); * // OK - disables SO_LINGER * </PRE> * <BR> * For an option that has a notion of on and off, and requires * a non-boolean parameter, setting its value to anything other than ! * <I>Boolean(false)</I> implicitly enables it. * <BR> * Throws SocketException if the option is unrecognized, * the socket is closed, or some low-level error occurred * <BR> * @param optID identifies the option --- 59,83 ---- * // ERROR - expects java.lang.Integer *</PRE> * If the requested option is binary, it can be set using this method by * a java.lang.Boolean: * <BR><PRE> ! * s.setOption(TCP_NODELAY, Boolean.TRUE); * // OK - enables TCP_NODELAY, a binary option * </PRE> * <BR> ! * Any option can be disabled using this method with a Boolean.FALSE: * <BR><PRE> ! * s.setOption(TCP_NODELAY, Boolean.FALSE); * // OK - disables TCP_NODELAY ! * s.setOption(SO_LINGER, Boolean.FALSE); * // OK - disables SO_LINGER * </PRE> * <BR> * For an option that has a notion of on and off, and requires * a non-boolean parameter, setting its value to anything other than ! * <I>Boolean.FALSE</I> implicitly enables it. * <BR> * Throws SocketException if the option is unrecognized, * the socket is closed, or some low-level error occurred * <BR> * @param optID identifies the option
*** 89,100 **** public void setOption(int optID, Object value) throws SocketException; /** * 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><PRE> * SocketImpl s; * ... * Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); * if (noDelay.booleanValue()) { --- 89,100 ---- public void setOption(int optID, Object value) throws SocketException; /** * 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><PRE> * SocketImpl s; * ... * Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); * if (noDelay.booleanValue()) {
*** 103,119 **** * } * </PRE> * <P> * 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): * <PRE> * 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); * } * </PRE> * * @param optID an {@code int} identifying the option to fetch * @return the value of the option --- 103,119 ---- * } * </PRE> * <P> * 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: * <PRE> * 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; * } * </PRE> * * @param optID an {@code int} identifying the option to fetch * @return the value of the option
< prev index next >