src/jdk.net/share/classes/jdk/net/RdmaSockets.java
author bpb
Thu, 07 Feb 2019 12:46:59 -0800
branchrsocket-branch
changeset 57161 d67b05ca1be4
parent 57160 c502c299d41e
permissions -rw-r--r--
rsocket-branch: correct some typos RdmaSockets
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     1
/*
57160
c502c299d41e rsocket-branch: correct copyright year
bpb
parents: 57157
diff changeset
     2
 * Copyright (c) 2018, 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.net;
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.net.ProtocolFamily;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    29
import java.net.ServerSocket;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    30
import java.net.Socket;
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    31
import java.net.StandardProtocolFamily;
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    32
import java.nio.channels.Selector;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    33
import java.nio.channels.ServerSocketChannel;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    34
import java.nio.channels.SocketChannel;
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    35
import java.nio.channels.spi.SelectorProvider;
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    36
import java.io.IOException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    37
import java.util.Objects;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    38
import jdk.internal.net.rdma.RdmaPollSelectorProvider;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    39
import jdk.internal.net.rdma.RdmaSocketProvider;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    40
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    41
/**
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    42
 * This class defines static factory methods to create sockets and channels to
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    43
 * RDMA-based sockets, and selectors to multiplex channels to RDMA sockets.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    44
 *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    45
 * <p> The {@linkplain #openSocket(ProtocolFamily) openSocket} and {@linkplain
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    46
 * #openServerSocket(ProtocolFamily) openServerSocket} methods create RDMA-based
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    47
 * TCP sockets.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    48
 *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    49
 * <p> The {@linkplain #openSocketChannel(ProtocolFamily) openSocketChannel} and
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    50
 * {@linkplain #openServerSocketChannel(ProtocolFamily) openServerSocketChannel}
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    51
 * methods open {@link java.nio.channels.SelectableChannel selectable channels}
57161
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    52
 * to RDMA sockets. The {@linkplain #openSelector() openSelector} method opens a
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    53
 * {@linkplain Selector} for multiplexing selectable channels to RDMA sockets.
57161
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    54
 * Selectable channels to RDMA sockets cannot be multiplexed with selectable
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    55
 * channels opened by the default system-wide {@link SelectorProvider selector
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    56
 * provider}. Furthermore, the RDMA selector provider does not support datagram
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    57
 * channels or pipes; its {@linkplain SelectorProvider#openDatagramChannel
57161
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    58
 * openDatagramChannel} and {@linkplain SelectorProvider#openPipe openPipe}
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    59
 * methods throw {@code UnsupportedOperationException}.
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    60
 *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    61
 * <p> Unless otherwise noted, passing a {@code null} argument will cause a
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    62
 * {@linkplain NullPointerException} to be thrown.
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    63
 *
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    64
 * @implNote The RDMA selector provider supports channels to both IPv4 and
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    65
 * IPv6 RDMA sockets. If the no-arg {@linkplain SelectorProvider#openSocketChannel()
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    66
 * openSocketChannel} or {@linkplain SelectorProvider#openServerSocketChannel()
57161
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    67
 * openServerSocketChannel} methods are used to open channels, then those
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    68
 * channels will be to IPv6 sockets if IPv6 is enabled on the platform (or
d67b05ca1be4 rsocket-branch: correct some typos RdmaSockets
bpb
parents: 57160
diff changeset
    69
 * IPv4 sockets if IPv6 is not enabled).
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    70
 *
57121
ff7b5750a610 rsocket-branch: update @since tags in API
chegar
parents: 57120
diff changeset
    71
 * @since 13
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    72
 */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    73
public class RdmaSockets {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    74
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    75
    private RdmaSockets() {}
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    76
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    77
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    78
     * Creates an unbound and unconnected RDMA socket.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    79
     *
57149
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
    80
     * <p> An RDMA socket supports the socket options
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
    81
     * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF},
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
    82
     * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR},
57153
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
    83
     * {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
    84
     * {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
    85
     * and those specified by {@link RdmaSocketOptions}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    86
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    87
     * <p> When {@link Socket#bind binding} the socket to a local address, or
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    88
     * {@link Socket#connect connecting} the socket, the socket address specified
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    89
     * to the {@code bind} and {@code connect} methods must correspond to the
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    90
     * protocol family specified here.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    91
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    92
     * @param  family
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
    93
     *         The protocol family
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    94
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    95
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    96
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    97
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    98
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    99
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   100
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   101
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   102
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   103
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   104
    public static Socket openSocket(ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   105
        Objects.requireNonNull(family, "protocol family is null");
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   106
        return RdmaSocketProvider.openSocket(family);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   107
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   108
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   109
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   110
     * Creates an unbound RDMA server socket.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   111
     *
57149
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
   112
     * <p> An RDMA server socket supports the socket options
57153
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   113
     * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   114
     * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   115
     * and those specified by {@link RdmaSocketOptions}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   116
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   117
     * <p> When binding the socket to an address, the socket address specified
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   118
     * to the {@linkplain ServerSocket#bind bind} method must correspond to the
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   119
     * protocol family specified here.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   120
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   121
     * @param family
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   122
     *        The protocol family
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   123
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   124
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   125
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   126
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   127
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   128
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   129
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   130
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   131
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   132
     */
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   133
    public static ServerSocket
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   134
    openServerSocket(ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   135
        Objects.requireNonNull(family, "protocol family is null");
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   136
        return RdmaSocketProvider.openServerSocket(family);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   137
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   138
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   139
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   140
     * Opens a socket channel to an RDMA socket. A newly created socket channel
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   141
     * is {@link java.nio.channels.Channel#isOpen() open} but not yet {@link
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   142
     * SocketChannel#bind bound} or {@link SocketChannel#isConnected() connected}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   143
     *
57149
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
   144
     * <p> A socket channel to an RDMA socket supports the socket options
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
   145
     * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF},
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
   146
     * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR},
57153
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   147
     * {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   148
     * {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   149
     * and those specified by {@link RdmaSocketOptions}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   150
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   151
     * <p> When binding the channel's socket to a local address, or {@link
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   152
     * SocketChannel#connect connecting} the channel's socket, the socket address
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   153
     * specified to the {@code bind} and {@code connect} methods must correspond
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   154
     * to the protocol family specified here.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   155
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   156
     * @param  family
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   157
     *         The protocol family
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   158
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   159
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   160
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   161
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   162
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   163
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   164
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   165
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   166
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   167
     */
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   168
    public static SocketChannel
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   169
    openSocketChannel(ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   170
        Objects.requireNonNull(family, "protocol family is null");
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   171
        return RdmaPollSelectorProvider.provider().openSocketChannel(family);
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   172
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   173
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   174
    /**
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   175
     * Opens a server-socket channel to an RDMA socket. A newly created
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   176
     * server-socket is {@link java.nio.channels.Channel#isOpen() open} but not
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   177
     * yet {@link ServerSocketChannel#bind bound}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   178
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   179
     * <p> A server-socket channel to an RDMA server socket supports the socket
57153
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   180
     * options {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   181
     * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR},
95c486f5c444 rsocket-branch: further clean up RdmaSockets options specification
bpb
parents: 57149
diff changeset
   182
     * and those specified by {@link RdmaSocketOptions}.
57149
87484051dbba rsocket-branch: clean up options spec in RdmaSockets
bpb
parents: 57142
diff changeset
   183
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   184
     * <p> When binding the channel's socket to a local address, the address
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   185
     * specified to the {@linkplain ServerSocketChannel#bind bind} method must
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   186
     * correspond to the protocol family specified here.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   187
     *
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   188
     * @param  family
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   189
     *         The protocol family
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   190
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   191
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   192
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   193
     * @throws UnsupportedOperationException
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   194
     *         If RDMA sockets are not supported on this platform or the
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   195
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   196
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   197
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   198
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   199
     */
57157
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   200
    public static ServerSocketChannel
12c7d6b3ec28 Tweak javadoc, fix links
alanb
parents: 57156
diff changeset
   201
    openServerSocketChannel(ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   202
        Objects.requireNonNull(family, "protocol family is null");
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   203
        return RdmaPollSelectorProvider.provider().openServerSocketChannel(family);
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   204
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   205
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   206
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   207
     * Opens a selector to multiplex selectable channels to RDMA sockets.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   208
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   209
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   210
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   211
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   212
     *         If RDMA sockets are not supported on this platform
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   213
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   214
    public static Selector openSelector() throws IOException {
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   215
        return RdmaPollSelectorProvider.provider().openSelector();
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   216
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   217
}