< prev index next >

src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java

Print this page
rev 55750 : UDS support, temporary commit

*** 28,37 **** --- 28,39 ---- import java.lang.reflect.Constructor; import java.io.FileDescriptor; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; + import java.net.SocketAddress; + import java.net.UnixSocketAddress; import java.nio.channels.Channel; import java.nio.channels.SocketChannel; import java.nio.channels.ServerSocketChannel; import java.nio.channels.DatagramChannel; import java.nio.channels.spi.SelectorProvider;
*** 75,85 **** */ public static class InheritedSocketChannelImpl extends SocketChannelImpl { InheritedSocketChannelImpl(SelectorProvider sp, FileDescriptor fd, ! InetSocketAddress remote) throws IOException { super(sp, fd, remote); } --- 77,87 ---- */ public static class InheritedSocketChannelImpl extends SocketChannelImpl { InheritedSocketChannelImpl(SelectorProvider sp, FileDescriptor fd, ! SocketAddress remote) throws IOException { super(sp, fd, remote); }
*** 180,197 **** SelectorProvider provider = SelectorProvider.provider(); assert provider instanceof sun.nio.ch.SelectorProviderImpl; Channel c; if (st == SOCK_STREAM) { ! InetAddress ia = peerAddress0(fdVal); ! if (ia == null) { c = new InheritedServerSocketChannelImpl(provider, fd); } else { ! int port = peerPort0(fdVal); ! assert port > 0; ! InetSocketAddress isa = new InetSocketAddress(ia, port); ! c = new InheritedSocketChannelImpl(provider, fd, isa); } } else { c = new InheritedDatagramChannelImpl(provider, fd); } return c; --- 182,201 ---- SelectorProvider provider = SelectorProvider.provider(); assert provider instanceof sun.nio.ch.SelectorProviderImpl; Channel c; if (st == SOCK_STREAM) { ! SocketAddress sa = peerAddress0(fdVal); ! if (sa == null) { c = new InheritedServerSocketChannelImpl(provider, fd); + } else if (sa instanceof InetSocketAddress) { + c = new InheritedSocketChannelImpl(provider, fd, sa); + } else if (sa instanceof UnixSocketAddress) { + // TODO: custom class for unix sockets + c = new InheritedSocketChannelImpl(provider, fd, sa); } else { ! throw new IllegalStateException("Unsupported socket type: " + sa.getClass().getName()); } } else { c = new InheritedDatagramChannelImpl(provider, fd); } return c;
*** 230,241 **** private static native int dup(int fd) throws IOException; private static native void dup2(int fd, int fd2) throws IOException; private static native int open0(String path, int oflag) throws IOException; private static native void close0(int fd) throws IOException; private static native int soType0(int fd); ! private static native InetAddress peerAddress0(int fd); ! private static native int peerPort0(int fd); static { IOUtil.load(); initIDs(); } --- 234,244 ---- private static native int dup(int fd) throws IOException; private static native void dup2(int fd, int fd2) throws IOException; private static native int open0(String path, int oflag) throws IOException; private static native void close0(int fd) throws IOException; private static native int soType0(int fd); ! private static native SocketAddress peerAddress0(int fd); static { IOUtil.load(); initIDs(); }
< prev index next >