--- old/src/jdk.net/share/classes/jdk/net/Sockets.java 2018-05-03 16:52:28.744492493 -0700 +++ new/src/jdk.net/share/classes/jdk/net/Sockets.java 2018-05-03 16:52:28.518492507 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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; /** @@ -350,4 +353,69 @@ available = s.contains(ExtendedSocketOptions.TCP_QUICKACK); } } + + /** + * Creates an unconnected RDMA socket + */ + public static Socket openRdmaSocket() throws IOException { + RdmaSocketImplFactory factory = new RdmaSocketImplFactory(); + SocketImpl impl = factory.createSocketImpl(); + return new Socket(impl) { }; + } + + /** + * Creates an unbound RDMA server socket + */ + public static ServerSocket openRdmaServerSocket() throws IOException { + RdmaSocketImplFactory factory = new RdmaSocketImplFactory(); + SocketImpl impl = factory.createSocketImpl(); + return new ServerSocket(impl) { }; + } + + /** + * 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(); + } }