Class UnixSocketChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.InterruptibleChannel, java.nio.channels.NetworkChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.WritableByteChannel, jnr.enxio.channels.NativeSelectableChannel

    public class UnixSocketChannel
    extends AbstractNativeSocketChannel
    A Channel implementation that uses a native unix socket
    • Method Detail

      • open

        public static final UnixSocketChannel open()
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • create

        public static final UnixSocketChannel create()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • pair

        public static final UnixSocketChannel[] pair()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • fromFD

        public static final UnixSocketChannel fromFD​(int fd)
        Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).
        Parameters:
        fd - the file descriptor to wrap
        Returns:
        the new UnixSocketChannel instance
      • connect

        public boolean connect​(UnixSocketAddress remote)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in class java.nio.channels.SocketChannel
      • isConnectionPending

        public boolean isConnectionPending()
        Specified by:
        isConnectionPending in class java.nio.channels.SocketChannel
      • finishConnect

        public boolean finishConnect()
                              throws java.io.IOException
        Specified by:
        finishConnect in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • connect

        public boolean connect​(java.net.SocketAddress remote)
                        throws java.io.IOException
        Specified by:
        connect in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • socket

        public UnixSocket socket()
        Specified by:
        socket in class java.nio.channels.SocketChannel
      • write

        public long write​(java.nio.ByteBuffer[] srcs,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.GatheringByteChannel
        Overrides:
        write in class AbstractNativeSocketChannel
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Overrides:
        read in class AbstractNativeSocketChannel
        Throws:
        java.io.IOException
      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Specified by:
        write in interface java.nio.channels.WritableByteChannel
        Overrides:
        write in class AbstractNativeSocketChannel
        Throws:
        java.io.IOException
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
                                                throws java.io.IOException
        Specified by:
        getRemoteAddress in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • getLocalAddress

        public java.net.SocketAddress getLocalAddress()
                                               throws java.io.IOException
        Specified by:
        getLocalAddress in interface java.nio.channels.NetworkChannel
        Specified by:
        getLocalAddress in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • supportedOptions

        public final java.util.Set<java.net.SocketOption<?>> supportedOptions()
      • getOption

        public <T> T getOption​(java.net.SocketOption<T> name)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setOption

        public <T> java.nio.channels.SocketChannel setOption​(java.net.SocketOption<T> name,
                                                             T value)
                                                      throws java.io.IOException
        Specified by:
        setOption in interface java.nio.channels.NetworkChannel
        Specified by:
        setOption in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException
      • bind

        public UnixSocketChannel bind​(java.net.SocketAddress local)
                               throws java.io.IOException
        Specified by:
        bind in interface java.nio.channels.NetworkChannel
        Specified by:
        bind in class java.nio.channels.SocketChannel
        Throws:
        java.io.IOException