src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaServerSocketAdaptor.java
author bpb
Wed, 06 Feb 2019 12:48:01 -0800
branchrsocket-branch
changeset 57156 81e4a12fd1a4
parent 57115 512e7cc6ccce
child 57160 c502c299d41e
permissions -rw-r--r--
rsocket-branch: change recent copyright year to 2019 and new files to 2019 only
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     1
/*
57156
81e4a12fd1a4 rsocket-branch: change recent copyright year to 2019 and new files to 2019 only
bpb
parents: 57115
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     4
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    10
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    16
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    20
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    23
 * questions.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    24
 */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    25
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    26
package jdk.internal.net.rdma;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    27
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    28
import java.io.IOException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    29
import java.net.InetAddress;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    30
import java.net.InetSocketAddress;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    31
import java.net.ServerSocket;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    32
import java.net.Socket;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    33
import java.net.SocketAddress;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    34
import java.net.SocketException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    35
import java.net.SocketTimeoutException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    36
import java.net.StandardSocketOptions;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    37
import java.nio.channels.IllegalBlockingModeException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    38
import java.nio.channels.NotYetBoundException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    39
import java.nio.channels.ServerSocketChannel;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    40
import java.nio.channels.SocketChannel;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    41
import sun.nio.ch.Net;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    42
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    43
class RdmaServerSocketAdaptor
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    44
    extends ServerSocket
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    45
{
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    46
    private final RdmaServerSocketChannelImpl ssc;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    47
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    48
    private volatile int timeout;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    49
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    50
    public static ServerSocket create(RdmaServerSocketChannelImpl ssc) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    51
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    52
            return new RdmaServerSocketAdaptor(ssc);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    53
        } catch (IOException x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    54
            throw new Error(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    55
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    56
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    57
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    58
    private RdmaServerSocketAdaptor(RdmaServerSocketChannelImpl ssc)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    59
            throws IOException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    60
        this.ssc = ssc;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    61
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    62
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    63
    public void bind(SocketAddress local) throws IOException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    64
        bind(local, 50);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    65
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    66
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    67
    public void bind(SocketAddress local, int backlog) throws IOException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    68
        if (local == null)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    69
            local = new InetSocketAddress(0);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    70
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    71
            ssc.bind(local, backlog);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    72
        } catch (Exception x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    73
            Net.translateException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    74
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    75
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    76
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    77
    public InetAddress getInetAddress() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    78
        InetSocketAddress local = ssc.localAddress();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    79
        if (local == null) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    80
            return null;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    81
        } else {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    82
            return Net.getRevealedLocalAddress(local).getAddress();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    83
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    84
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    85
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    86
    public int getLocalPort() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    87
        InetSocketAddress local = ssc.localAddress();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    88
        if (local == null) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    89
            return -1;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    90
        } else {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    91
            return local.getPort();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    92
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    93
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    94
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    95
    public Socket accept() throws IOException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    96
        synchronized (ssc.blockingLock()) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    97
            try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    98
                if (!ssc.isBound())
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    99
                    throw new NotYetBoundException();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   100
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   101
                long to = this.timeout;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   102
                if (to == 0) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   103
                    // for compatibility reasons: accept connection if available
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   104
                    // when configured non-blocking
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   105
                    SocketChannel sc = ssc.accept();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   106
                    if (sc == null && !ssc.isBlocking())
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   107
                        throw new IllegalBlockingModeException();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   108
                    return sc.socket();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   109
                }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   110
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   111
                if (!ssc.isBlocking())
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   112
                    throw new IllegalBlockingModeException();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   113
                for (;;) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   114
                    long st = System.currentTimeMillis();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   115
                    if (ssc.pollAccept(to))
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   116
                        return ssc.accept().socket();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   117
                    to -= System.currentTimeMillis() - st;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   118
                    if (to <= 0)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   119
                        throw new SocketTimeoutException();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   120
                }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   121
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   122
            } catch (Exception x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   123
                Net.translateException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   124
                assert false;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   125
                return null;            // Never happens
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   126
            }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   127
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   128
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   129
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   130
    public void close() throws IOException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   131
        ssc.close();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   132
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   133
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   134
    public ServerSocketChannel getChannel() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   135
        return ssc;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   136
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   137
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   138
    public boolean isBound() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   139
        return ssc.isBound();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   140
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   141
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   142
    public boolean isClosed() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   143
        return !ssc.isOpen();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   144
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   145
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   146
    public void setSoTimeout(int timeout) throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   147
        this.timeout = timeout;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   148
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   149
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   150
    public int getSoTimeout() throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   151
        return timeout;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   152
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   153
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   154
    public void setReuseAddress(boolean on) throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   155
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   156
            ssc.setOption(StandardSocketOptions.SO_REUSEADDR, on);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   157
        } catch (IOException x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   158
            Net.translateToSocketException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   159
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   160
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   161
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   162
    public boolean getReuseAddress() throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   163
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   164
            return ssc.getOption(StandardSocketOptions.SO_REUSEADDR)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   165
                      .booleanValue();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   166
        } catch (IOException x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   167
            Net.translateToSocketException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   168
            return false;       // Never happens
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   169
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   170
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   171
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   172
    public String toString() {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   173
        if (!isBound())
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   174
            return "RdmaServerSocket[unbound]";
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   175
        return "RdmaServerSocket[addr=" + getInetAddress() +
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   176
               ",localport=" + getLocalPort()  + "]";
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   177
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   178
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   179
    public void setReceiveBufferSize(int size) throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   180
        // size 0 valid for ServerSocketChannel, invalid for ServerSocket
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   181
        if (size <= 0)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   182
            throw new IllegalArgumentException("size cannot be 0 or negative");
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   183
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   184
            ssc.setOption(StandardSocketOptions.SO_RCVBUF, size);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   185
        } catch (IOException x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   186
            Net.translateToSocketException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   187
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   188
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   189
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   190
    public int getReceiveBufferSize() throws SocketException {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   191
        try {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   192
            return ssc.getOption(StandardSocketOptions.SO_RCVBUF).intValue();
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   193
        } catch (IOException x) {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   194
            Net.translateToSocketException(x);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   195
            return -1;          // Never happens
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   196
        }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   197
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   198
}