< prev index next >

src/jdk.net/share/classes/jdk/net/Sockets.java

Print this page

        

@@ -24,16 +24,19 @@
  */
 
 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;
 
 /**
  * Defines static methods to set and get socket options defined by the
  * {@link java.net.SocketOption} interface. All of the standard options defined

@@ -373,6 +376,81 @@
             AVAILABLE = s.containsAll(Set.of(ExtendedSocketOptions.TCP_KEEPCOUNT,
                                             ExtendedSocketOptions.TCP_KEEPIDLE,
                                             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.
+     *
+     * <p> 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.
+     *
+     * <p> 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.  </p>
+     *
+     * @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();
+    }
 }
< prev index next >