jdk/src/windows/classes/java/net/PlainSocketImpl.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8185 6bf10e071117
child 11019 aa969c520286
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8185
diff changeset
     2
 * Copyright (c) 2007, 2011, 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: 715
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: 715
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: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.net;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This class PlainSocketImpl simply delegates to the appropriate real
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * SocketImpl. We do this because PlainSocketImpl is already extended
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * by SocksSocketImpl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * There are two possibilities for the real SocketImpl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * TwoStacksPlainSocketImpl or DualStackPlainSocketImpl. We use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * DualStackPlainSocketImpl on systems that have a dual stack
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * TCP implementation. Otherwise we create an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * TwoStacksPlainSocketImpl and delegate to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author Chris Hegarty
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
class PlainSocketImpl extends AbstractPlainSocketImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private AbstractPlainSocketImpl impl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /* the windows version. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static float version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /* java.net.preferIPv4Stack */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static boolean preferIPv4Stack = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /* If the version supports a dual stack TCP implementation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static boolean useDualStackImpl = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                    version = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                        version = Float.parseFloat(System.getProperties().getProperty("os.version"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                        preferIPv4Stack = Boolean.parseBoolean(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                          System.getProperties().getProperty("java.net.preferIPv4Stack"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                    } catch (NumberFormatException e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                        assert false : e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                    return null; // nothing to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                } });
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        // (version >= 6.0) implies Vista or greater.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (version >= 6.0 && !preferIPv4Stack) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            useDualStackImpl = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Constructs an empty instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    PlainSocketImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        if (useDualStackImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            impl = new DualStackPlainSocketImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            impl = new TwoStacksPlainSocketImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Constructs an instance with the given file descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    PlainSocketImpl(FileDescriptor fd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (useDualStackImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            impl = new DualStackPlainSocketImpl(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            impl = new TwoStacksPlainSocketImpl(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // Override methods in SocketImpl that access impl's fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    protected FileDescriptor getFileDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return impl.getFileDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    protected InetAddress getInetAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        return impl.getInetAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    protected int getPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return impl.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    protected int getLocalPort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return impl.getLocalPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    void setSocket(Socket soc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        impl.setSocket(soc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    Socket getSocket() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return impl.getSocket();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    void setServerSocket(ServerSocket soc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        impl.setServerSocket(soc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    ServerSocket getServerSocket() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        return impl.getServerSocket();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        return impl.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    // Override methods in AbstractPlainSocketImpl that access impl's fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected synchronized void create(boolean stream) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        impl.create(stream);
8185
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   141
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   142
        // set fd to delegate's fd to be compatible with older releases
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   143
        this.fd = impl.fd;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    protected void connect(String host, int port)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        throws UnknownHostException, IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        impl.connect(host, port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    protected void connect(InetAddress address, int port) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        impl.connect(address, port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    protected void connect(SocketAddress address, int timeout) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        impl.connect(address, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public void setOption(int opt, Object val) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        impl.setOption(opt, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public Object getOption(int opt) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return impl.getOption(opt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        impl.doConnect(address, port, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
8185
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   172
    protected synchronized void bind(InetAddress address, int lport)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        impl.bind(address, lport);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    protected synchronized void accept(SocketImpl s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // pass in the real impl not the wrapper.
8185
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   180
        SocketImpl delegate = ((PlainSocketImpl)s).impl;
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   181
        delegate.address = new InetAddress();
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   182
        delegate.fd = new FileDescriptor();
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   183
        impl.accept(delegate);
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   184
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   185
        // set fd to delegate's fd to be compatible with older releases
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   186
        s.fd = delegate.fd;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    void setFileDescriptor(FileDescriptor fd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        impl.setFileDescriptor(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    void setAddress(InetAddress address) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        impl.setAddress(address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    void setPort(int port) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        impl.setPort(port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    void setLocalPort(int localPort) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        impl.setLocalPort(localPort);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    protected synchronized InputStream getInputStream() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return impl.getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    void setInputStream(SocketInputStream in) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        impl.setInputStream(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    protected synchronized OutputStream getOutputStream() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return impl.getOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    protected void close() throws IOException {
8185
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   218
        try {
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   219
            impl.close();
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   220
        } finally {
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   221
            // set fd to delegate's fd to be compatible with older releases
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   222
            this.fd = null;
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   223
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    void reset() throws IOException {
8185
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   227
        try {
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   228
            impl.reset();
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   229
        } finally {
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   230
            // set fd to delegate's fd to be compatible with older releases
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   231
            this.fd = null;
6bf10e071117 7016898: PlainSocketImpl.fd is null on Windows
chegar
parents: 5506
diff changeset
   232
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    protected void shutdownInput() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        impl.shutdownInput();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    protected void shutdownOutput() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        impl.shutdownOutput();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    protected void sendUrgentData(int data) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        impl.sendUrgentData(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    FileDescriptor acquireFD() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return impl.acquireFD();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    void releaseFD() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        impl.releaseFD();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public boolean isConnectionReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return impl.isConnectionReset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public boolean isConnectionResetPending() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return impl.isConnectionResetPending();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public void setConnectionReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        impl.setConnectionReset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public void setConnectionResetPending() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        impl.setConnectionResetPending();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public boolean isClosedOrPending() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return impl.isClosedOrPending();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public int getTimeout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return impl.getTimeout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    // Override methods in AbstractPlainSocketImpl that need to be implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    void socketCreate(boolean isServer) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        impl.socketCreate(isServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    void socketConnect(InetAddress address, int port, int timeout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        impl.socketConnect(address, port, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    void socketBind(InetAddress address, int port)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        impl.socketBind(address, port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    void socketListen(int count) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        impl.socketListen(count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    void socketAccept(SocketImpl s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        impl.socketAccept(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    int socketAvailable() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return impl.socketAvailable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    void socketClose0(boolean useDeferredClose) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        impl.socketClose0(useDeferredClose);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    void socketShutdown(int howto) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        impl.socketShutdown(howto);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    void socketSetOption(int cmd, boolean on, Object value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        socketSetOption(cmd, on, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    int socketGetOption(int opt, Object iaContainerObj) throws SocketException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return impl.socketGetOption(opt, iaContainerObj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    void socketSendUrgentData(int data) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        impl.socketSendUrgentData(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
}