src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java
branchunixdomainchannels
changeset 58801 119ac9128c1b
parent 47216 71c04702a3d5
child 58847 692de65ab293
--- a/src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java	Fri Oct 25 14:50:16 2019 +0100
+++ b/src/java.base/share/classes/sun/nio/ch/SelectorProviderImpl.java	Fri Oct 25 15:56:35 2019 +0100
@@ -30,6 +30,7 @@
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.ProtocolFamily;
+import java.net.StandardProtocolFamily;
 import java.nio.channels.*;
 import java.nio.channels.spi.*;
 
@@ -53,10 +54,32 @@
     public abstract AbstractSelector openSelector() throws IOException;
 
     public ServerSocketChannel openServerSocketChannel() throws IOException {
-        return new ServerSocketChannelImpl(this);
+        return new InetServerSocketChannelImpl(this);
     }
 
     public SocketChannel openSocketChannel() throws IOException {
-        return new SocketChannelImpl(this);
+        return new InetSocketChannelImpl(this);
+    }
+
+    public SocketChannel openSocketChannel(ProtocolFamily family) throws IOException {
+        // TODO: This doesn't exclusively implement the given family
+        if (family == StandardProtocolFamily.INET || family == StandardProtocolFamily.INET6) {
+            throw new UnsupportedOperationException("This will be supported, but is not implemented yet");
+            //return new InetSocketChannelImpl(this);
+        } else if (family == StandardProtocolFamily.UNIX) {
+            return new UnixDomainSocketChannelImpl(this, Net.unixDomainSocket(), false);
+        } else
+            throw new UnsupportedAddressTypeException();
+    }
+
+    public ServerSocketChannel openServerSocketChannel(ProtocolFamily family) throws IOException {
+        // TODO: This doesn't exclusively implement the given family
+        if (family == StandardProtocolFamily.INET || family == StandardProtocolFamily.INET6) {
+            throw new UnsupportedOperationException("This will be supported, but is not implemented yet");
+            //return new InetServerSocketChannelImpl(this);
+        } else if (family == StandardProtocolFamily.UNIX) {
+            return new UnixDomainServerSocketChannelImpl(this);
+        } else
+            throw new UnsupportedAddressTypeException();
     }
 }