Package jnr.unixsocket
Class UnixSocketChannel
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,GatheringByteChannel,InterruptibleChannel,NetworkChannel,ReadableByteChannel,ScatteringByteChannel,WritableByteChannel,jnr.enxio.channels.NativeSelectableChannel
public class UnixSocketChannel extends AbstractNativeSocketChannel
AChannelimplementation 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:
isConnectedin classSocketChannel
-
isConnectionPending
public boolean isConnectionPending()
- Specified by:
isConnectionPendingin classSocketChannel
-
finishConnect
public boolean finishConnect() throws IOException- Specified by:
finishConnectin classSocketChannel- Throws:
IOException
-
getRemoteSocketAddress
public final UnixSocketAddress getRemoteSocketAddress()
-
getLocalSocketAddress
public final UnixSocketAddress getLocalSocketAddress()
-
connect
public boolean connect(SocketAddress remote) throws IOException
- Specified by:
connectin classSocketChannel- Throws:
IOException
-
socket
public UnixSocket socket()
- Specified by:
socketin classSocketChannel
-
write
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
- Specified by:
writein interfaceGatheringByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
IOException
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
readin interfaceReadableByteChannel- Overrides:
readin classAbstractNativeSocketChannel- Throws:
IOException
-
write
public int write(ByteBuffer src) throws IOException
- Specified by:
writein interfaceWritableByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
IOException
-
getRemoteAddress
public SocketAddress getRemoteAddress() throws IOException
- Specified by:
getRemoteAddressin classSocketChannel- Throws:
IOException
-
getLocalAddress
public SocketAddress getLocalAddress() throws IOException
- Specified by:
getLocalAddressin interfaceNetworkChannel- Specified by:
getLocalAddressin 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:
setOptionin interfaceNetworkChannel- Specified by:
setOptionin classSocketChannel- Throws:
IOException
-
bind
public UnixSocketChannel bind(SocketAddress local) throws IOException
- Specified by:
bindin interfaceNetworkChannel- Specified by:
bindin classSocketChannel- Throws:
IOException
-
-