< prev index next >

src/java.base/share/classes/java/net/ServerSocket.java

Print this page

        

@@ -74,14 +74,15 @@
      * Are we using an older SocketImpl?
      */
     private boolean oldImpl = false;
 
     /**
-     * Package-private constructor to create a ServerSocket associated with
-     * the given SocketImpl.
+     * Creates a server socket with a user-specified SocketImpl.
+     *
+     * @param      impl the user-specified SocketImpl
      */
-    ServerSocket(SocketImpl impl) {
+    protected ServerSocket(SocketImpl impl) {
         this.impl = impl;
         impl.setServerSocket(this);
     }
 
     /**

@@ -513,11 +514,24 @@
     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 = new Socket((SocketImpl) null);
+
+        Socket s = null;
+        Class<?> cls = impl.getClass();
+        if (cls.getName().contains("RdmaSocketImpl")) {
+            try {
+                Constructor<?> c = cls.getConstructor();
+                s = new Socket((SocketImpl)c.newInstance());
+            } catch (NoSuchMethodException | InstantiationException |
+                IllegalAccessException | InvocationTargetException e) {
+                throw new AssertionError(e);
+            }
+        } else {
+            s = new Socket((SocketImpl) null);
+        }
         implAccept(s);
         return s;
     }
 
     /**

@@ -544,12 +558,12 @@
             else {
                 s.impl.reset();
             }
             si = s.impl;
             s.impl = null;
-            si.address = new InetAddress();
-            si.fd = new FileDescriptor();
+            si.setAddress(new InetAddress());
+            si.setFileDescriptor(new FileDescriptor());
             getImpl().accept(si);
             SocketCleanable.register(si.fd);   // raw fd has been set
 
             SecurityManager security = System.getSecurityManager();
             if (security != null) {
< prev index next >