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

Print this page




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.net;
  27 
  28 import java.lang.annotation.Native;
  29 
  30 /**
  31  * Interface of methods to get/set socket options.  This interface is
  32  * implemented by: <B>SocketImpl</B> and  <B>DatagramSocketImpl</B>.
  33  * Subclasses of these should override the methods
  34  * of this interface in order to support their own options.
  35  * <P>
  36  * The methods and constants which specify options in this interface are
  37  * for implementation only.  If you're not subclassing SocketImpl or
  38  * DatagramSocketImpl, <B>you won't use these directly.</B> There are
  39  * type-safe methods to get/set each of these options in Socket, ServerSocket,
  40  * DatagramSocket and MulticastSocket.
  41  * <P>
  42  * @author David Brown
  43  */
  44 
  45 
  46 public interface SocketOptions {
  47 
  48     /**
  49      * Enable/disable the option specified by <I>optID</I>.  If the option
  50      * is to be enabled, and it takes an option-specific "value",  this is
  51      * passed in <I>value</I>.  The actual type of value is option-specific,
  52      * and it is an error to pass something that isn't of the expected type:
  53      * <BR><PRE>
  54      * SocketImpl s;
  55      * ...
  56      * s.setOption(SO_LINGER, new Integer(10));
  57      *    // OK - set SO_LINGER w/ timeout of 10 sec.
  58      * s.setOption(SO_LINGER, new Double(10));
  59      *    // ERROR - expects java.lang.Integer
  60      *</PRE>
  61      * If the requested option is binary, it can be set using this method by




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.net;
  27 
  28 import java.lang.annotation.Native;
  29 
  30 /**
  31  * Interface of methods to get/set socket options.  This interface is
  32  * implemented by: <B>SocketImpl</B> and  <B>DatagramSocketImpl</B>.
  33  * Subclasses of these should override the methods
  34  * of this interface in order to support their own options.
  35  * <P>
  36  * The methods and constants which specify options in this interface are
  37  * for implementation only.  If you're not subclassing SocketImpl or
  38  * DatagramSocketImpl, <B>you won't use these directly.</B> There are
  39  * type-safe methods to get/set each of these options in Socket, ServerSocket,
  40  * DatagramSocket and MulticastSocket.
  41  *
  42  * @author David Brown
  43  */
  44 
  45 
  46 public interface SocketOptions {
  47 
  48     /**
  49      * Enable/disable the option specified by <I>optID</I>.  If the option
  50      * is to be enabled, and it takes an option-specific "value",  this is
  51      * passed in <I>value</I>.  The actual type of value is option-specific,
  52      * and it is an error to pass something that isn't of the expected type:
  53      * <BR><PRE>
  54      * SocketImpl s;
  55      * ...
  56      * s.setOption(SO_LINGER, new Integer(10));
  57      *    // OK - set SO_LINGER w/ timeout of 10 sec.
  58      * s.setOption(SO_LINGER, new Double(10));
  59      *    // ERROR - expects java.lang.Integer
  60      *</PRE>
  61      * If the requested option is binary, it can be set using this method by