jdk/src/java.base/share/classes/java/net/SocketOptions.java
changeset 32649 2ee9017c7597
parent 25859 3317bb8137f4
child 33672 971eeb07166a
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
   137      *
   137      *
   138      * @see Socket#setTcpNoDelay
   138      * @see Socket#setTcpNoDelay
   139      * @see Socket#getTcpNoDelay
   139      * @see Socket#getTcpNoDelay
   140      */
   140      */
   141 
   141 
   142     @Native public final static int TCP_NODELAY = 0x0001;
   142     @Native public static final int TCP_NODELAY = 0x0001;
   143 
   143 
   144     /**
   144     /**
   145      * Fetch the local address binding of a socket (this option cannot
   145      * Fetch the local address binding of a socket (this option cannot
   146      * be "set" only "gotten", since sockets are bound at creation time,
   146      * be "set" only "gotten", since sockets are bound at creation time,
   147      * and so the locally bound address cannot be changed).  The default local
   147      * and so the locally bound address cannot be changed).  The default local
   158      *
   158      *
   159      * @see Socket#getLocalAddress
   159      * @see Socket#getLocalAddress
   160      * @see DatagramSocket#getLocalAddress
   160      * @see DatagramSocket#getLocalAddress
   161      */
   161      */
   162 
   162 
   163     @Native public final static int SO_BINDADDR = 0x000F;
   163     @Native public static final int SO_BINDADDR = 0x000F;
   164 
   164 
   165     /** Sets SO_REUSEADDR for a socket.  This is used only for MulticastSockets
   165     /** Sets SO_REUSEADDR for a socket.  This is used only for MulticastSockets
   166      * in java, and it is set by default for MulticastSockets.
   166      * in java, and it is set by default for MulticastSockets.
   167      * <P>
   167      * <P>
   168      * Valid for: DatagramSocketImpl
   168      * Valid for: DatagramSocketImpl
   169      */
   169      */
   170 
   170 
   171     @Native public final static int SO_REUSEADDR = 0x04;
   171     @Native public static final int SO_REUSEADDR = 0x04;
   172 
   172 
   173     /**
   173     /**
   174      * Sets SO_BROADCAST for a socket. This option enables and disables
   174      * Sets SO_BROADCAST for a socket. This option enables and disables
   175      * the ability of the process to send broadcast messages. It is supported
   175      * the ability of the process to send broadcast messages. It is supported
   176      * for only datagram sockets and only on networks that support
   176      * for only datagram sockets and only on networks that support
   177      * the concept of a broadcast message (e.g. Ethernet, token ring, etc.),
   177      * the concept of a broadcast message (e.g. Ethernet, token ring, etc.),
   178      * and it is set by default for DatagramSockets.
   178      * and it is set by default for DatagramSockets.
   179      * @since 1.4
   179      * @since 1.4
   180      */
   180      */
   181 
   181 
   182     @Native public final static int SO_BROADCAST = 0x0020;
   182     @Native public static final int SO_BROADCAST = 0x0020;
   183 
   183 
   184     /** Set which outgoing interface on which to send multicast packets.
   184     /** Set which outgoing interface on which to send multicast packets.
   185      * Useful on hosts with multiple network interfaces, where applications
   185      * Useful on hosts with multiple network interfaces, where applications
   186      * want to use other than the system default.  Takes/returns an InetAddress.
   186      * want to use other than the system default.  Takes/returns an InetAddress.
   187      * <P>
   187      * <P>
   189      *
   189      *
   190      * @see MulticastSocket#setInterface(InetAddress)
   190      * @see MulticastSocket#setInterface(InetAddress)
   191      * @see MulticastSocket#getInterface()
   191      * @see MulticastSocket#getInterface()
   192      */
   192      */
   193 
   193 
   194     @Native public final static int IP_MULTICAST_IF = 0x10;
   194     @Native public static final int IP_MULTICAST_IF = 0x10;
   195 
   195 
   196     /** Same as above. This option is introduced so that the behaviour
   196     /** Same as above. This option is introduced so that the behaviour
   197      *  with IP_MULTICAST_IF will be kept the same as before, while
   197      *  with IP_MULTICAST_IF will be kept the same as before, while
   198      *  this new option can support setting outgoing interfaces with either
   198      *  this new option can support setting outgoing interfaces with either
   199      *  IPv4 and IPv6 addresses.
   199      *  IPv4 and IPv6 addresses.
   201      *  NOTE: make sure there is no conflict with this
   201      *  NOTE: make sure there is no conflict with this
   202      * @see MulticastSocket#setNetworkInterface(NetworkInterface)
   202      * @see MulticastSocket#setNetworkInterface(NetworkInterface)
   203      * @see MulticastSocket#getNetworkInterface()
   203      * @see MulticastSocket#getNetworkInterface()
   204      * @since 1.4
   204      * @since 1.4
   205      */
   205      */
   206     @Native public final static int IP_MULTICAST_IF2 = 0x1f;
   206     @Native public static final int IP_MULTICAST_IF2 = 0x1f;
   207 
   207 
   208     /**
   208     /**
   209      * This option enables or disables local loopback of multicast datagrams.
   209      * This option enables or disables local loopback of multicast datagrams.
   210      * This option is enabled by default for Multicast Sockets.
   210      * This option is enabled by default for Multicast Sockets.
   211      * @since 1.4
   211      * @since 1.4
   212      */
   212      */
   213 
   213 
   214     @Native public final static int IP_MULTICAST_LOOP = 0x12;
   214     @Native public static final int IP_MULTICAST_LOOP = 0x12;
   215 
   215 
   216     /**
   216     /**
   217      * This option sets the type-of-service or traffic class field
   217      * This option sets the type-of-service or traffic class field
   218      * in the IP header for a TCP or UDP socket.
   218      * in the IP header for a TCP or UDP socket.
   219      * @since 1.4
   219      * @since 1.4
   220      */
   220      */
   221 
   221 
   222     @Native public final static int IP_TOS = 0x3;
   222     @Native public static final int IP_TOS = 0x3;
   223 
   223 
   224     /**
   224     /**
   225      * Specify a linger-on-close timeout.  This option disables/enables
   225      * Specify a linger-on-close timeout.  This option disables/enables
   226      * immediate return from a <B>close()</B> of a TCP Socket.  Enabling
   226      * immediate return from a <B>close()</B> of a TCP Socket.  Enabling
   227      * this option with a non-zero Integer <I>timeout</I> means that a
   227      * this option with a non-zero Integer <I>timeout</I> means that a
   235      * Valid only for TCP: SocketImpl
   235      * Valid only for TCP: SocketImpl
   236      *
   236      *
   237      * @see Socket#setSoLinger
   237      * @see Socket#setSoLinger
   238      * @see Socket#getSoLinger
   238      * @see Socket#getSoLinger
   239      */
   239      */
   240     @Native public final static int SO_LINGER = 0x0080;
   240     @Native public static final int SO_LINGER = 0x0080;
   241 
   241 
   242     /** Set a timeout on blocking Socket operations:
   242     /** Set a timeout on blocking Socket operations:
   243      * <PRE>
   243      * <PRE>
   244      * ServerSocket.accept();
   244      * ServerSocket.accept();
   245      * SocketInputStream.read();
   245      * SocketInputStream.read();
   256      *
   256      *
   257      * @see Socket#setSoTimeout
   257      * @see Socket#setSoTimeout
   258      * @see ServerSocket#setSoTimeout
   258      * @see ServerSocket#setSoTimeout
   259      * @see DatagramSocket#setSoTimeout
   259      * @see DatagramSocket#setSoTimeout
   260      */
   260      */
   261     @Native public final static int SO_TIMEOUT = 0x1006;
   261     @Native public static final int SO_TIMEOUT = 0x1006;
   262 
   262 
   263     /**
   263     /**
   264      * Set a hint the size of the underlying buffers used by the
   264      * Set a hint the size of the underlying buffers used by the
   265      * platform for outgoing network I/O. When used in set, this is a
   265      * platform for outgoing network I/O. When used in set, this is a
   266      * suggestion to the kernel from the application about the size of
   266      * suggestion to the kernel from the application about the size of
   273      * @see Socket#setSendBufferSize
   273      * @see Socket#setSendBufferSize
   274      * @see Socket#getSendBufferSize
   274      * @see Socket#getSendBufferSize
   275      * @see DatagramSocket#setSendBufferSize
   275      * @see DatagramSocket#setSendBufferSize
   276      * @see DatagramSocket#getSendBufferSize
   276      * @see DatagramSocket#getSendBufferSize
   277      */
   277      */
   278     @Native public final static int SO_SNDBUF = 0x1001;
   278     @Native public static final int SO_SNDBUF = 0x1001;
   279 
   279 
   280     /**
   280     /**
   281      * Set a hint the size of the underlying buffers used by the
   281      * Set a hint the size of the underlying buffers used by the
   282      * platform for incoming network I/O. When used in set, this is a
   282      * platform for incoming network I/O. When used in set, this is a
   283      * suggestion to the kernel from the application about the size of
   283      * suggestion to the kernel from the application about the size of
   291      * @see Socket#setReceiveBufferSize
   291      * @see Socket#setReceiveBufferSize
   292      * @see Socket#getReceiveBufferSize
   292      * @see Socket#getReceiveBufferSize
   293      * @see DatagramSocket#setReceiveBufferSize
   293      * @see DatagramSocket#setReceiveBufferSize
   294      * @see DatagramSocket#getReceiveBufferSize
   294      * @see DatagramSocket#getReceiveBufferSize
   295      */
   295      */
   296     @Native public final static int SO_RCVBUF = 0x1002;
   296     @Native public static final int SO_RCVBUF = 0x1002;
   297 
   297 
   298     /**
   298     /**
   299      * When the keepalive option is set for a TCP socket and no data
   299      * When the keepalive option is set for a TCP socket and no data
   300      * has been exchanged across the socket in either direction for
   300      * has been exchanged across the socket in either direction for
   301      * 2 hours (NOTE: the actual value is implementation dependent),
   301      * 2 hours (NOTE: the actual value is implementation dependent),
   314      * Valid only for TCP socket: SocketImpl
   314      * Valid only for TCP socket: SocketImpl
   315      *
   315      *
   316      * @see Socket#setKeepAlive
   316      * @see Socket#setKeepAlive
   317      * @see Socket#getKeepAlive
   317      * @see Socket#getKeepAlive
   318      */
   318      */
   319     @Native public final static int SO_KEEPALIVE = 0x0008;
   319     @Native public static final int SO_KEEPALIVE = 0x0008;
   320 
   320 
   321     /**
   321     /**
   322      * When the OOBINLINE option is set, any TCP urgent data received on
   322      * When the OOBINLINE option is set, any TCP urgent data received on
   323      * the socket will be received through the socket input stream.
   323      * the socket will be received through the socket input stream.
   324      * When the option is disabled (which is the default) urgent data
   324      * When the option is disabled (which is the default) urgent data
   325      * is silently discarded.
   325      * is silently discarded.
   326      *
   326      *
   327      * @see Socket#setOOBInline
   327      * @see Socket#setOOBInline
   328      * @see Socket#getOOBInline
   328      * @see Socket#getOOBInline
   329      */
   329      */
   330     @Native public final static int SO_OOBINLINE = 0x1003;
   330     @Native public static final int SO_OOBINLINE = 0x1003;
   331 }
   331 }