-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,GatheringByteChannel
,InterruptibleChannel
,NetworkChannel
,ReadableByteChannel
,ScatteringByteChannel
,WritableByteChannel
,jnr.enxio.channels.NativeSelectableChannel
public class UnixSocketChannel extends AbstractNativeSocketChannel
AChannel
implementation that uses a native unix socket
-
-
Method Summary
-
Methods inherited from class jnr.unixsocket.impl.AbstractNativeSocketChannel
getFD, implCloseSelectableChannel, implConfigureBlocking, read, setFD, shutdownInput, shutdownOutput
-
Methods inherited from class java.nio.channels.SocketChannel
open, read, validOps, write
-
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
-
Methods inherited from class java.nio.channels.SelectableChannel
register
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Method Detail
-
open
public static final UnixSocketChannel open() throws IOException
- Throws:
IOException
-
open
public static final UnixSocketChannel open(UnixSocketAddress remote) throws IOException
- Throws:
IOException
-
create
public static final UnixSocketChannel create() throws IOException
- Throws:
IOException
-
pair
public static final UnixSocketChannel[] pair() throws IOException
- Throws:
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 IOException
- Throws:
IOException
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in classSocketChannel
-
isConnectionPending
public boolean isConnectionPending()
- Specified by:
isConnectionPending
in classSocketChannel
-
finishConnect
public boolean finishConnect() throws IOException
- Specified by:
finishConnect
in classSocketChannel
- Throws:
IOException
-
getRemoteSocketAddress
public final UnixSocketAddress getRemoteSocketAddress()
-
getLocalSocketAddress
public final UnixSocketAddress getLocalSocketAddress()
-
connect
public boolean connect(SocketAddress remote) throws IOException
- Specified by:
connect
in classSocketChannel
- Throws:
IOException
-
socket
public UnixSocket socket()
- Specified by:
socket
in classSocketChannel
-
write
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
- Specified by:
write
in interfaceGatheringByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
IOException
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Overrides:
read
in classAbstractNativeSocketChannel
- Throws:
IOException
-
write
public int write(ByteBuffer src) throws IOException
- Specified by:
write
in interfaceWritableByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
IOException
-
getRemoteAddress
public SocketAddress getRemoteAddress() throws IOException
- Specified by:
getRemoteAddress
in classSocketChannel
- Throws:
IOException
-
getLocalAddress
public SocketAddress getLocalAddress() throws IOException
- Specified by:
getLocalAddress
in interfaceNetworkChannel
- Specified by:
getLocalAddress
in classSocketChannel
- Throws:
IOException
-
supportedOptions
public final Set<SocketOption<?>> supportedOptions()
-
getOption
public <T> T getOption(SocketOption<T> name) throws IOException
- Throws:
IOException
-
setOption
public <T> SocketChannel setOption(SocketOption<T> name, T value) throws IOException
- Specified by:
setOption
in interfaceNetworkChannel
- Specified by:
setOption
in classSocketChannel
- Throws:
IOException
-
bind
public UnixSocketChannel bind(SocketAddress local) throws IOException
- Specified by:
bind
in interfaceNetworkChannel
- Specified by:
bind
in classSocketChannel
- Throws:
IOException
-
-