--- old/src/jdk.net/share/classes/jdk/net/Sockets.java 2018-06-04 11:02:22.803275254 -0700 +++ new/src/jdk.net/share/classes/jdk/net/Sockets.java 2018-06-04 11:02:22.523275249 -0700 @@ -26,12 +26,15 @@ package jdk.net; import java.net.*; +import java.nio.channels.*; import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import rdma.ch.RdmaPollSelectorProvider; +import rdma.ch.RdmaSocketImpl; import jdk.net.ExtendedSocketOptions.PlatformSocketOptions; /** @@ -375,4 +378,79 @@ ExtendedSocketOptions.TCP_KEEPINTERVAL)); } } + + /** + * Creates an unconnected RDMA socket + */ + public static Socket openRdmaSocket() throws IOException { + SocketImpl impl = new RdmaSocketImpl(); + return new Socket(impl) { }; + } + + /** + * Creates an unbound RDMA server socket + */ + public static ServerSocket openRdmaServerSocket() throws IOException { + SocketImpl impl = new RdmaSocketImpl(); + ServerSocket ss = new ServerSocket(impl) { + public Socket accept() throws IOException { + if (isClosed()) + throw new SocketException("Socket is closed"); + if (!isBound()) + throw new SocketException("Socket is not bound yet"); + + Socket s = openRdmaSocket(); + implAccept(s); + return s; + } + }; + return ss; + } + + /** + * Opens a RDMA socket channel. + * + * @return A new RDMA socket channel + * + * @throws IOException + * If an I/O error occurs + */ + public static SocketChannel openRdmaSocketChannel() throws IOException { + return RdmaPollSelectorProvider.provider().openSocketChannel(); + } + + /** + * Opens a RDMA server-socket channel. + * + *

The new channel is created by invoking the {@link + * java.nio.channels.spi.SelectorProvider#openServerSocketChannel + * openServerSocketChannel} method of the system-wide default {@link + * java.nio.channels.spi.SelectorProvider} object. + * + *

The new channel's socket is initially unbound; it must be bound to a + * specific address via one of its socket's {@link + * java.net.ServerSocket#bind(SocketAddress) bind} methods before + * connections can be accepted.

+ * + * @return A new RDMA server socket channel + * + * @throws IOException + * If an I/O error occurs + */ + public static ServerSocketChannel openRdmaServerSocketChannel() + throws IOException { + return RdmaPollSelectorProvider.provider().openServerSocketChannel(); + } + + /** + * Opens a RDMA selector. + * + * @return A new RDMA selector + * + * @throws IOException + * If an I/O error occurs + */ + public static Selector openRdmaSelector() throws IOException { + return RdmaPollSelectorProvider.provider().openSelector(); + } }