src/java.base/share/classes/java/net/DatagramSocketImpl.java
author alanb
Mon, 29 Apr 2019 09:03:06 +0100
branchniosocketimpl-branch
changeset 57341 733e9746d615
parent 47216 71c04702a3d5
child 55081 dd321e3596c0
permissions -rw-r--r--
More cleanup and test improvements
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: 35302
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.FileDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    30
import java.util.Set;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Abstract datagram and multicast socket implementation base class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @author Pavani Diwanji
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 24046
diff changeset
    35
 * @since  1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public abstract class DatagramSocketImpl implements SocketOptions {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * The local port number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    protected int localPort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * The file descriptor object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    protected FileDescriptor fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    51
     * The DatagramSocket or MulticastSocket
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    52
     * that owns this impl
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    53
     */
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    54
    DatagramSocket socket;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    55
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    56
    void setDatagramSocket(DatagramSocket socket) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    57
        this.socket = socket;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    58
    }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    59
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    60
    DatagramSocket getDatagramSocket() {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    61
        return socket;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    62
    }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    63
27078
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    64
    int dataAvailable() {
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    65
        // default impl returns zero, which disables the calling
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    66
        // functionality
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    67
        return 0;
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    68
    }
39275d6a8cac 8039509: Wrap sockets more thoroughly
michaelm
parents: 25859
diff changeset
    69
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
    70
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Creates a datagram socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @exception SocketException if there is an error in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * underlying protocol, such as a TCP error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected abstract void create() throws SocketException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Binds a datagram socket to a local port and address.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param lport the local port
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param laddr the local address
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @exception SocketException if there is an error in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * underlying protocol, such as a TCP error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected abstract void bind(int lport, InetAddress laddr) throws SocketException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Sends a datagram packet. The packet contains the data and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * destination address to send the packet to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param p the packet to be sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @exception IOException if an I/O exception occurs while sending the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * datagram packet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @exception  PortUnreachableException may be thrown if the socket is connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * to a currently unreachable destination. Note, there is no guarantee that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * the exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    protected abstract void send(DatagramPacket p) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Connects a datagram socket to a remote destination. This associates the remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * address with the local socket so that datagrams may only be sent to this destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * and received from this destination. This may be overridden to call a native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * system connect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <p>If the remote destination to which the socket is connected does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * exist, or is otherwise unreachable, and if an ICMP destination unreachable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * packet has been received for that address, then a subsequent call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * send or receive may throw a PortUnreachableException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Note, there is no guarantee that the exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param address the remote InetAddress to connect to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param port the remote port number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @exception   SocketException may be thrown if the socket cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * connected to the remote destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected void connect(InetAddress address, int port) throws SocketException {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Disconnects a datagram socket from its remote destination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    protected void disconnect() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   124
     * Peek at the packet to see who it is from. Updates the specified {@code InetAddress}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * to the address which the packet came from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param i an InetAddress object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @return the port number which the packet came from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @exception  PortUnreachableException may be thrown if the socket is connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *       to a currently unreachable destination. Note, there is no guarantee that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *       exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    protected abstract int peek(InetAddress i) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Peek at the packet to see who it is from. The data is copied into the specified
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   137
     * {@code DatagramPacket}. The data is returned,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * but not consumed, so that a subsequent peekData/receive operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * will see the same data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param p the Packet Received.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @return the port number which the packet came from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @exception  PortUnreachableException may be thrown if the socket is connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *       to a currently unreachable destination. Note, there is no guarantee that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *       exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    protected abstract int peekData(DatagramPacket p) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Receive the datagram packet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param p the Packet Received.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * while receiving the datagram packet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @exception  PortUnreachableException may be thrown if the socket is connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *       to a currently unreachable destination. Note, there is no guarantee that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *       exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    protected abstract void receive(DatagramPacket p) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Set the TTL (time-to-live) option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param ttl a byte specifying the TTL value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @deprecated use setTimeToLive instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @exception IOException if an I/O exception occurs while setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * the time-to-live option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @see #getTTL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    protected abstract void setTTL(byte ttl) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Retrieve the TTL (time-to-live) option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * while retrieving the time-to-live option
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @deprecated use getTimeToLive instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @return a byte representing the TTL value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @see #setTTL(byte)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    protected abstract byte getTTL() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Set the TTL (time-to-live) option.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   186
     * @param ttl an {@code int} specifying the time-to-live value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * while setting the time-to-live option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @see #getTimeToLive()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    protected abstract void setTimeToLive(int ttl) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Retrieve the TTL (time-to-live) option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * while retrieving the time-to-live option
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   197
     * @return an {@code int} representing the time-to-live value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @see #setTimeToLive(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    protected abstract int getTimeToLive() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Join the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param inetaddr multicast address to join.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * while joining the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    protected abstract void join(InetAddress inetaddr) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Leave the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param inetaddr multicast address to leave.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @exception IOException if an I/O exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * while leaving the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    protected abstract void leave(InetAddress inetaddr) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Join the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @param mcastaddr address to join.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @param netIf specifies the local interface to receive multicast
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *        datagram packets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @throws IOException if an I/O exception occurs while joining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * the multicast group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    protected abstract void joinGroup(SocketAddress mcastaddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                      NetworkInterface netIf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Leave the multicast group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @param mcastaddr address to leave.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @param netIf specified the local interface to leave the group at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @throws IOException if an I/O exception occurs while leaving
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * the multicast group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    protected abstract void leaveGroup(SocketAddress mcastaddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                       NetworkInterface netIf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Close the socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    protected abstract void close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Gets the local port.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   250
     * @return an {@code int} representing the local port value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    protected int getLocalPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        return localPort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Gets the datagram socket file descriptor.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 5506
diff changeset
   258
     * @return a {@code FileDescriptor} object representing the datagram socket
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * file descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    protected FileDescriptor getFileDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   264
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   265
    /**
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   266
     * Called to set a socket option.
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   267
     *
28852
a581c7868768 8041395: Doclint regression in java.net.SocketOption
darcy
parents: 27078
diff changeset
   268
     * @param <T> The type of the socket option value
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   269
     * @param name The socket option
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   270
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   271
     * @param value The value of the socket option. A value of {@code null}
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   272
     *              may be valid for some options.
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   273
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   274
     * @throws UnsupportedOperationException if the DatagramSocketImpl does not
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   275
     *         support the option
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   276
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   277
     * @throws NullPointerException if name is {@code null}
28852
a581c7868768 8041395: Doclint regression in java.net.SocketOption
darcy
parents: 27078
diff changeset
   278
     * @throws IOException if an I/O problem occurs while attempting to set the option
35302
e4d2275861c3 8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents: 28852
diff changeset
   279
     * @since 9
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   280
     */
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   281
    protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   282
        if (name == StandardSocketOptions.SO_SNDBUF) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   283
            setOption(SocketOptions.SO_SNDBUF, value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   284
        } else if (name == StandardSocketOptions.SO_RCVBUF) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   285
            setOption(SocketOptions.SO_RCVBUF, value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   286
        } else if (name == StandardSocketOptions.SO_REUSEADDR) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   287
            setOption(SocketOptions.SO_REUSEADDR, value);
36115
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   288
        } else if (name == StandardSocketOptions.SO_REUSEPORT &&
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   289
            supportedOptions().contains(name)) {
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   290
            setOption(SocketOptions.SO_REUSEPORT, value);
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   291
        } else if (name == StandardSocketOptions.IP_TOS) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   292
            setOption(SocketOptions.IP_TOS, value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   293
        } else if (name == StandardSocketOptions.IP_MULTICAST_IF &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   294
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   295
            setOption(SocketOptions.IP_MULTICAST_IF2, value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   296
        } else if (name == StandardSocketOptions.IP_MULTICAST_TTL &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   297
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   298
            if (! (value instanceof Integer)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   299
                throw new IllegalArgumentException("not an integer");
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   300
            }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   301
            setTimeToLive((Integer)value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   302
        } else if (name == StandardSocketOptions.IP_MULTICAST_LOOP &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   303
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   304
            setOption(SocketOptions.IP_MULTICAST_LOOP, value);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   305
        } else {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   306
            throw new UnsupportedOperationException("unsupported option");
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   307
        }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   308
    }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   309
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   310
    /**
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   311
     * Called to get a socket option.
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   312
     *
28852
a581c7868768 8041395: Doclint regression in java.net.SocketOption
darcy
parents: 27078
diff changeset
   313
     * @return the socket option
a581c7868768 8041395: Doclint regression in java.net.SocketOption
darcy
parents: 27078
diff changeset
   314
     * @param <T> The type of the socket option value
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   315
     * @param name The socket option
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   316
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   317
     * @throws UnsupportedOperationException if the DatagramSocketImpl does not
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   318
     *         support the option
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   319
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   320
     * @throws NullPointerException if name is {@code null}
28852
a581c7868768 8041395: Doclint regression in java.net.SocketOption
darcy
parents: 27078
diff changeset
   321
     * @throws IOException if an I/O problem occurs while attempting to set the option
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   322
     *
35302
e4d2275861c3 8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents: 28852
diff changeset
   323
     * @since 9
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   324
     */
24046
d1f6da65881a 8041397: Lint regression in java.net.SocketOption
michaelm
parents: 23879
diff changeset
   325
    @SuppressWarnings("unchecked")
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   326
    protected <T> T getOption(SocketOption<T> name) throws IOException {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   327
        if (name == StandardSocketOptions.SO_SNDBUF) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   328
            return (T) getOption(SocketOptions.SO_SNDBUF);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   329
        } else if (name == StandardSocketOptions.SO_RCVBUF) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   330
            return (T) getOption(SocketOptions.SO_RCVBUF);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   331
        } else if (name == StandardSocketOptions.SO_REUSEADDR) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   332
            return (T) getOption(SocketOptions.SO_REUSEADDR);
36115
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   333
        } else if (name == StandardSocketOptions.SO_REUSEPORT &&
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   334
            supportedOptions().contains(name)) {
0676e37a0b9c 6432031: Add support for SO_REUSEPORT
alanb
parents: 35302
diff changeset
   335
            return (T) getOption(SocketOptions.SO_REUSEPORT);
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   336
        } else if (name == StandardSocketOptions.IP_TOS) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   337
            return (T) getOption(SocketOptions.IP_TOS);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   338
        } else if (name == StandardSocketOptions.IP_MULTICAST_IF &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   339
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   340
            return (T) getOption(SocketOptions.IP_MULTICAST_IF2);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   341
        } else if (name == StandardSocketOptions.IP_MULTICAST_TTL &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   342
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   343
            Integer ttl = getTimeToLive();
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   344
            return (T)ttl;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   345
        } else if (name == StandardSocketOptions.IP_MULTICAST_LOOP &&
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   346
            (getDatagramSocket() instanceof MulticastSocket)) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   347
            return (T) getOption(SocketOptions.IP_MULTICAST_LOOP);
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   348
        } else {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   349
            throw new UnsupportedOperationException("unsupported option");
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   350
        }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   351
    }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   352
36228
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   353
    private static final Set<SocketOption<?>> dgSocketOptions;
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   354
36228
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   355
    private static final Set<SocketOption<?>> mcSocketOptions;
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   356
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   357
    static {
36228
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   358
        dgSocketOptions = Set.of(StandardSocketOptions.SO_SNDBUF,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   359
                                 StandardSocketOptions.SO_RCVBUF,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   360
                                 StandardSocketOptions.SO_REUSEADDR,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   361
                                 StandardSocketOptions.IP_TOS);
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   362
36228
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   363
        mcSocketOptions = Set.of(StandardSocketOptions.SO_SNDBUF,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   364
                                 StandardSocketOptions.SO_RCVBUF,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   365
                                 StandardSocketOptions.SO_REUSEADDR,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   366
                                 StandardSocketOptions.IP_TOS,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   367
                                 StandardSocketOptions.IP_MULTICAST_IF,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   368
                                 StandardSocketOptions.IP_MULTICAST_TTL,
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   369
                                 StandardSocketOptions.IP_MULTICAST_LOOP);
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   370
    }
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   371
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   372
    /**
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   373
     * Returns a set of SocketOptions supported by this impl
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   374
     * and by this impl's socket (DatagramSocket or MulticastSocket)
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   375
     *
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   376
     * @return a Set of SocketOptions
36228
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   377
     *
a16a22218e23 8148609: socket impl supportedOptions() should return an immutable set
vtewari
parents: 36115
diff changeset
   378
     * @since 9
23879
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   379
     */
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   380
    protected Set<SocketOption<?>> supportedOptions() {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   381
        if (getDatagramSocket() instanceof MulticastSocket) {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   382
            return mcSocketOptions;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   383
        } else {
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   384
            return dgSocketOptions;
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   385
        }
284802a2d355 8036979: Support java.net.SocketOption<> in java.net socket types
michaelm
parents: 19069
diff changeset
   386
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
}