jdk/src/share/classes/sun/security/ssl/BaseSSLSocketImpl.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 1580 9af5946d4060
child 14194 971f46db533d
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1580
diff changeset
     2
 * Copyright (c) 2002, 2008, 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: 1580
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: 1580
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: 1580
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1580
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1580
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package sun.security.ssl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.nio.channels.SocketChannel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.net.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.net.ssl.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Abstract base class for SSLSocketImpl. Its purpose is to house code with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * no SSL related logic (or no logic at all). This makes SSLSocketImpl shorter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and easier to read. It contains a few constants and static methods plus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * overridden java.net.Socket methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Methods are defined final to ensure that they are not accidentally
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * overridden in SSLSocketImpl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see javax.net.ssl.SSLSocket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see SSLSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
abstract class BaseSSLSocketImpl extends SSLSocket {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Normally "self" is "this" ... but not when this connection is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * layered over a preexisting socket.  If we're using an existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * socket, we delegate some actions to it.  Else, we delegate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * instead to "super".  This is important to ensure that we don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * recurse infinitely ... e.g. close() calling itself, or doing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * I/O in terms of our own streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    final Socket self;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    BaseSSLSocketImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        this.self = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    BaseSSLSocketImpl(Socket socket) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.self = socket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // CONSTANTS AND STATIC METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * TLS requires that a close_notify warning alert is sent before the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * connection is closed in order to avoid truncation attacks. Some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * implementations (MS IIS and others) don't do that. The property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * below controls whether we accept that or treat it as an error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * The default is "false", i.e. tolerate the broken behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private final static String PROP_NAME =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                "com.sun.net.ssl.requireCloseNotify";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    final static boolean requireCloseNotify =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                Debug.getBooleanProperty(PROP_NAME, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    // MISC SOCKET METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Returns the unique {@link java.nio.SocketChannel SocketChannel} object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * associated with this socket, if any.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see java.net.Socket#getChannel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public final SocketChannel getChannel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return super.getChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            return self.getChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Binds the address to the socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @see java.net.Socket#bind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public void bind(SocketAddress bindpoint) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
         * Bind to this socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            super.bind(bindpoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            // If we're binding on a layered socket...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            throw new IOException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                "Underlying socket should already be connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Returns the address of the endpoint this socket is connected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @see java.net.Socket#getLocalSocketAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public SocketAddress getLocalSocketAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            return super.getLocalSocketAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            return self.getLocalSocketAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Returns the address of the endpoint this socket is connected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see java.net.Socket#getRemoteSocketAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public SocketAddress getRemoteSocketAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            return super.getRemoteSocketAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            return self.getRemoteSocketAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Connects this socket to the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * This method is either called on an unconnected SSLSocketImpl by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * application, or it is called in the constructor of a regular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * SSLSocketImpl. If we are layering on top on another socket, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * this method should not be called, because we assume that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * underlying socket is already connected by the time it is passed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * us.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param   endpoint the <code>SocketAddress</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @throws  IOException if an error occurs during the connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public final void connect(SocketAddress endpoint) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        connect(endpoint, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Returns the connection state of the socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see java.net.Socket#isConnected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public final boolean isConnected() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            return super.isConnected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            return self.isConnected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Returns the binding state of the socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @see java.net.Socket#isBound
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public final boolean isBound() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            return super.isBound();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            return self.isBound();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    // CLOSE RELATED METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * The semantics of shutdownInput is not supported in TLS 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * spec. Thus when the method is called on an SSL socket, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * UnsupportedOperationException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @throws UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public final void shutdownInput() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        throw new UnsupportedOperationException("The method shutdownInput()" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                   " is not supported in SSLSocket");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * The semantics of shutdownOutput is not supported in TLS 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * spec. Thus when the method is called on an SSL socket, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * UnsupportedOperationException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @throws UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public final void shutdownOutput() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        throw new UnsupportedOperationException("The method shutdownOutput()" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                   " is not supported in SSLSocket");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Returns the input state of the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @see java.net.Socket#isInputShutdown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public final boolean isInputShutdown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return super.isInputShutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return self.isInputShutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Returns the output state of the socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @see java.net.Socket#isOutputShutdown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public final boolean isOutputShutdown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            return super.isOutputShutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            return self.isOutputShutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Ensures that the SSL connection is closed down as cleanly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * as possible, in case the application forgets to do so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * This allows SSL connections to be implicitly reclaimed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * rather than forcing them to be explicitly reclaimed at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * the penalty of prematurly killing SSL sessions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    protected final void finalize() throws Throwable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        } catch (IOException e1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                    super.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            } catch (IOException e2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        } finally {
1580
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   259
            // We called close on the underlying socket above to
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   260
            // make doubly sure all resources got released.  We
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   261
            // don't finalize self in the case of overlain sockets,
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   262
            // that's a different object which the GC will finalize
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   263
            // separately.
9af5946d4060 6745052: SLServerSocket file descriptor leak
xuelei
parents: 2
diff changeset
   264
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            super.finalize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    // GET ADDRESS METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Returns the address of the remote peer for this connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    public final InetAddress getInetAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            return super.getInetAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            return self.getInetAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Gets the local address to which the socket is bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @return the local address to which the socket is bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public final InetAddress getLocalAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            return super.getLocalAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            return self.getLocalAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Returns the number of the remote port that this connection uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public final int getPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            return super.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            return self.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * Returns the number of the local port that this connection uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public final int getLocalPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            return super.getLocalPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            return self.getLocalPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    // SOCKET OPTION METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Enables or disables the Nagle optimization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see java.net.Socket#setTcpNoDelay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public final void setTcpNoDelay(boolean value) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            super.setTcpNoDelay(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            self.setTcpNoDelay(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Returns true if the Nagle optimization is disabled.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * relates to low-level buffering of TCP traffic, delaying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * traffic to promote better throughput.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @see java.net.Socket#getTcpNoDelay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    public final boolean getTcpNoDelay() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            return super.getTcpNoDelay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            return self.getTcpNoDelay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * Assigns the socket's linger timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @see java.net.Socket#setSoLinger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    public final void setSoLinger(boolean flag, int linger)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            super.setSoLinger(flag, linger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            self.setSoLinger(flag, linger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Returns the socket's linger timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @see java.net.Socket#getSoLinger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public final int getSoLinger() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            return super.getSoLinger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            return self.getSoLinger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Send one byte of urgent data on the socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see java.net.Socket#sendUrgentData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * At this point, there seems to be no specific requirement to support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * this for an SSLSocket. An implementation can be provided if a need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * arises in future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public final void sendUrgentData(int data) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        throw new SocketException("This method is not supported "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                        + "by SSLSockets");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * option is disabled and TCP urgent data received on a socket is silently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * discarded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @see java.net.Socket#setOOBInline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Setting OOBInline does not have any effect on SSLSocket,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * since currently we don't support sending urgent data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    public final void setOOBInline(boolean on) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        throw new SocketException("This method is ineffective, since"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                + " sending urgent data is not supported by SSLSockets");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Tests if OOBINLINE is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see java.net.Socket#getOOBInline
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public final boolean getOOBInline() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        throw new SocketException("This method is ineffective, since"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                + " sending urgent data is not supported by SSLSockets");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Returns the socket timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @see java.net.Socket#getSoTimeout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public final int getSoTimeout() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            return super.getSoTimeout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            return self.getSoTimeout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public final void setSendBufferSize(int size) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            super.setSendBufferSize(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            self.setSendBufferSize(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public final int getSendBufferSize() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            return super.getSendBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            return self.getSendBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public final void setReceiveBufferSize(int size) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            super.setReceiveBufferSize(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            self.setReceiveBufferSize(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public final int getReceiveBufferSize() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            return super.getReceiveBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            return self.getReceiveBufferSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Enable/disable SO_KEEPALIVE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see java.net.Socket#setKeepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public final void setKeepAlive(boolean on) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            super.setKeepAlive(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            self.setKeepAlive(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * Tests if SO_KEEPALIVE is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @see java.net.Socket#getKeepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public final boolean getKeepAlive() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            return super.getKeepAlive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            return self.getKeepAlive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * Sets traffic class or type-of-service octet in the IP header for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * packets sent from this Socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @see java.net.Socket#setTrafficClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    public final void setTrafficClass(int tc) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            super.setTrafficClass(tc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            self.setTrafficClass(tc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * Gets traffic class or type-of-service in the IP header for packets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * sent from this Socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see java.net.Socket#getTrafficClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public final int getTrafficClass() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            return super.getTrafficClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            return self.getTrafficClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * Enable/disable SO_REUSEADDR.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @see java.net.Socket#setReuseAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    public final void setReuseAddress(boolean on) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            super.setReuseAddress(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            self.setReuseAddress(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Tests if SO_REUSEADDR is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see java.net.Socket#getReuseAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    public final boolean getReuseAddress() throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            return super.getReuseAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            return self.getReuseAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * Sets performance preferences for this socket.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @see java.net.Socket#setPerformancePreferences(int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    public void setPerformancePreferences(int connectionTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            int latency, int bandwidth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        if (self == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            super.setPerformancePreferences(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                connectionTime, latency, bandwidth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            self.setPerformancePreferences(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                connectionTime, latency, bandwidth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
}