jdk/src/java.base/share/classes/java/net/SocketOptions.java
author alanb
Tue, 23 Feb 2016 17:41:00 +0000
changeset 36115 0676e37a0b9c
parent 33672 971eeb07166a
child 45434 4582657c7260
permissions -rw-r--r--
6432031: Add support for SO_REUSEPORT Reviewed-by: alanb, simonis, chegar Contributed-by: yingqi.lu@intel.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
36115
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
     2
 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.net;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
15136
c17824042364 8005856: build-infra: Remove special handling of base module classes header generation
erikj
parents: 5506
diff changeset
    28
import java.lang.annotation.Native;
c17824042364 8005856: build-infra: Remove special handling of base module classes header generation
erikj
parents: 5506
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Interface of methods to get/set socket options.  This interface is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * implemented by: <B>SocketImpl</B> and  <B>DatagramSocketImpl</B>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Subclasses of these should override the methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * of this interface in order to support their own options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * The methods and constants which specify options in this interface are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * for implementation only.  If you're not subclassing SocketImpl or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * DatagramSocketImpl, <B>you won't use these directly.</B> There are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * type-safe methods to get/set each of these options in Socket, ServerSocket,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * DatagramSocket and MulticastSocket.
23720
7d5147c21927 8039172: Tidy warnings cleanup for java.net, java.math, java.time, java.rmi
yan
parents: 21334
diff changeset
    41
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author David Brown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public interface SocketOptions {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * Enable/disable the option specified by <I>optID</I>.  If the option
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * is to be enabled, and it takes an option-specific "value",  this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * passed in <I>value</I>.  The actual type of value is option-specific,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * and it is an error to pass something that isn't of the expected type:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * <BR><PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * SocketImpl s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * s.setOption(SO_LINGER, new Integer(10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     *    // OK - set SO_LINGER w/ timeout of 10 sec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * s.setOption(SO_LINGER, new Double(10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *    // ERROR - expects java.lang.Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * If the requested option is binary, it can be set using this method by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * a java.lang.Boolean:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * <BR><PRE>
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    64
     * s.setOption(TCP_NODELAY, Boolean.TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *    // OK - enables TCP_NODELAY, a binary option
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <BR>
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    68
     * Any option can be disabled using this method with a Boolean.FALSE:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * <BR><PRE>
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    70
     * s.setOption(TCP_NODELAY, Boolean.FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *    // OK - disables TCP_NODELAY
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    72
     * s.setOption(SO_LINGER, Boolean.FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *    // OK - disables SO_LINGER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * <BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * For an option that has a notion of on and off, and requires
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * a non-boolean parameter, setting its value to anything other than
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    78
     * <I>Boolean.FALSE</I> implicitly enables it.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Throws SocketException if the option is unrecognized,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * the socket is closed, or some low-level error occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * <BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param optID identifies the option
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param value the parameter of the socket option
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @throws SocketException if the option is unrecognized,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * the socket is closed, or some low-level error occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @see #getOption(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        setOption(int optID, Object value) throws SocketException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Fetch the value of an option.
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    94
     * Binary options will return java.lang.Boolean.TRUE
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
    95
     * if enabled, java.lang.Boolean.FALSE if disabled, e.g.:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * <BR><PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * SocketImpl s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * if (noDelay.booleanValue()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *     // true if TCP_NODELAY is enabled...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * For options that take a particular type as a parameter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * getOption(int) will return the parameter's value, else
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
   108
     * it will return java.lang.Boolean.FALSE:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Object o = s.getOption(SO_LINGER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * if (o instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *     System.out.print("Linger time is " + ((Integer)o).intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * } else {
33672
971eeb07166a 8141662: Javadoc fix. Do not suggest to use new Boolean(true).
sebastian
parents: 32649
diff changeset
   114
     *   // the true type of o is java.lang.Boolean.FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 15136
diff changeset
   118
     * @param optID an {@code int} identifying the option to fetch
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @return the value of the option
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @throws SocketException if the socket is closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @throws SocketException if <I>optID</I> is unknown along the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *         protocol stack (including the SocketImpl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @see #setOption(int, java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public Object getOption(int optID) throws SocketException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * The java-supported BSD-style options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Disable Nagle's algorithm for this connection.  Written data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * to the network is not buffered pending acknowledgement of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * previously written data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Valid for TCP only: SocketImpl.
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19069
diff changeset
   137
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see Socket#setTcpNoDelay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @see Socket#getTcpNoDelay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   142
    @Native public static final int TCP_NODELAY = 0x0001;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Fetch the local address binding of a socket (this option cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * be "set" only "gotten", since sockets are bound at creation time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * and so the locally bound address cannot be changed).  The default local
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * address of a socket is INADDR_ANY, meaning any local address on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * multi-homed host.  A multi-homed host can use this option to accept
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * connections to only one of its addresses (in the case of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * ServerSocket or DatagramSocket), or to specify its return address
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * to the peer (for a Socket or DatagramSocket).  The parameter of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * this option is an InetAddress.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * This option <B>must</B> be specified in the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Valid for: SocketImpl, DatagramSocketImpl
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19069
diff changeset
   158
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see Socket#getLocalAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see DatagramSocket#getLocalAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   163
    @Native public static final int SO_BINDADDR = 0x000F;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /** Sets SO_REUSEADDR for a socket.  This is used only for MulticastSockets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * in java, and it is set by default for MulticastSockets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Valid for: DatagramSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   171
    @Native public static final int SO_REUSEADDR = 0x04;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
36115
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   173
    /** Sets SO_REUSEPORT for a socket. This option enables and disables
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   174
     *  the ability to have multiple sockets listen to the same address
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   175
     *  and port.
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   176
     * <P>
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   177
     * Valid for: SocketImpl, DatagramSocketImpl
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   178
     *
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   179
     * @since 9
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   180
     * @see StandardSocketOptions#SO_REUSEPORT
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   181
     */
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   182
    @Native public static final int SO_REUSEPORT = 0x0E;
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 33672
diff changeset
   183
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Sets SO_BROADCAST for a socket. This option enables and disables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * the ability of the process to send broadcast messages. It is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * for only datagram sockets and only on networks that support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * the concept of a broadcast message (e.g. Ethernet, token ring, etc.),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * and it is set by default for DatagramSockets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   193
    @Native public static final int SO_BROADCAST = 0x0020;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /** Set which outgoing interface on which to send multicast packets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Useful on hosts with multiple network interfaces, where applications
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * want to use other than the system default.  Takes/returns an InetAddress.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Valid for Multicast: DatagramSocketImpl
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19069
diff changeset
   200
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see MulticastSocket#setInterface(InetAddress)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @see MulticastSocket#getInterface()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   205
    @Native public static final int IP_MULTICAST_IF = 0x10;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /** Same as above. This option is introduced so that the behaviour
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *  with IP_MULTICAST_IF will be kept the same as before, while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *  this new option can support setting outgoing interfaces with either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *  IPv4 and IPv6 addresses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *  NOTE: make sure there is no conflict with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @see MulticastSocket#setNetworkInterface(NetworkInterface)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @see MulticastSocket#getNetworkInterface()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   217
    @Native public static final int IP_MULTICAST_IF2 = 0x1f;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * This option enables or disables local loopback of multicast datagrams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * This option is enabled by default for Multicast Sockets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   225
    @Native public static final int IP_MULTICAST_LOOP = 0x12;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * This option sets the type-of-service or traffic class field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * in the IP header for a TCP or UDP socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   233
    @Native public static final int IP_TOS = 0x3;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Specify a linger-on-close timeout.  This option disables/enables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * immediate return from a <B>close()</B> of a TCP Socket.  Enabling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * this option with a non-zero Integer <I>timeout</I> means that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * <B>close()</B> will block pending the transmission and acknowledgement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * of all data written to the peer, at which point the socket is closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * <I>gracefully</I>.  Upon reaching the linger timeout, the socket is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * closed <I>forcefully</I>, with a TCP RST. Enabling the option with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * timeout of zero does a forceful close immediately. If the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * timeout value exceeds 65,535 it will be reduced to 65,535.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Valid only for TCP: SocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @see Socket#setSoLinger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @see Socket#getSoLinger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   251
    @Native public static final int SO_LINGER = 0x0080;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /** Set a timeout on blocking Socket operations:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * ServerSocket.accept();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * SocketInputStream.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * DatagramSocket.receive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * <P> The option must be set prior to entering a blocking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * operation to take effect.  If the timeout expires and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * operation would continue to block,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * <B>java.io.InterruptedIOException</B> is raised.  The Socket is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * not closed in this case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * <P> Valid for all sockets: SocketImpl, DatagramSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @see Socket#setSoTimeout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @see ServerSocket#setSoTimeout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @see DatagramSocket#setSoTimeout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   272
    @Native public static final int SO_TIMEOUT = 0x1006;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Set a hint the size of the underlying buffers used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * platform for outgoing network I/O. When used in set, this is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * suggestion to the kernel from the application about the size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * buffers to use for the data to be sent over the socket. When
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * used in get, this must return the size of the buffer actually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * used by the platform when sending out data on this socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Valid for all sockets: SocketImpl, DatagramSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @see Socket#setSendBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @see Socket#getSendBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @see DatagramSocket#setSendBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @see DatagramSocket#getSendBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   289
    @Native public static final int SO_SNDBUF = 0x1001;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Set a hint the size of the underlying buffers used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * platform for incoming network I/O. When used in set, this is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * suggestion to the kernel from the application about the size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * buffers to use for the data to be received over the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * socket. When used in get, this must return the size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * buffer actually used by the platform when receiving in data on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * this socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Valid for all sockets: SocketImpl, DatagramSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see Socket#setReceiveBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @see Socket#getReceiveBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @see DatagramSocket#setReceiveBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * @see DatagramSocket#getReceiveBufferSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   307
    @Native public static final int SO_RCVBUF = 0x1002;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * When the keepalive option is set for a TCP socket and no data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * has been exchanged across the socket in either direction for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * 2 hours (NOTE: the actual value is implementation dependent),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * TCP automatically sends a keepalive probe to the peer. This probe is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * TCP segment to which the peer must respond.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * One of three responses is expected:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * 1. The peer responds with the expected ACK. The application is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *    notified (since everything is OK). TCP will send another probe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *    following another 2 hours of inactivity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * 2. The peer responds with an RST, which tells the local TCP that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *    the peer host has crashed and rebooted. The socket is closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * 3. There is no response from the peer. The socket is closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * The purpose of this option is to detect if the peer host crashes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Valid only for TCP socket: SocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @see Socket#setKeepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see Socket#getKeepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   330
    @Native public static final int SO_KEEPALIVE = 0x0008;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * When the OOBINLINE option is set, any TCP urgent data received on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * the socket will be received through the socket input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * When the option is disabled (which is the default) urgent data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * is silently discarded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @see Socket#setOOBInline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @see Socket#getOOBInline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   341
    @Native public static final int SO_OOBINLINE = 0x1003;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
}