Package jnr.unixsocket
Class UnixSocketChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,GatheringByteChannel
,InterruptibleChannel
,NetworkChannel
,ReadableByteChannel
,ScatteringByteChannel
,WritableByteChannel
,jnr.enxio.channels.NativeSelectableChannel
A
Channel
implementation that uses a native unix
socket-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
(package private) static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BindHandler
private UnixSocketAddress
private UnixSocketAddress
private UnixSocketChannel.State
private final ReadWriteLock
-
Constructor Summary
ConstructorsConstructorDescriptionUnixSocketChannel
(int fd) UnixSocketChannel
(int fd, UnixSocketChannel.State initialState, boolean initialBoundState) -
Method Summary
Modifier and TypeMethodDescriptionbind
(SocketAddress local) boolean
connect
(SocketAddress remote) boolean
connect
(UnixSocketAddress remote) static final UnixSocketChannel
create()
private boolean
doConnect
(SockAddrUnix remote) boolean
static final UnixSocketChannel
fromFD
(int fd) Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).final UnixSocketAddress
<T> T
getOption
(SocketOption<T> name) final UnixSocketAddress
(package private) boolean
isBound()
boolean
boolean
private boolean
isIdle()
static final UnixSocketChannel
open()
static final UnixSocketChannel
open
(UnixSocketAddress remote) static final UnixSocketChannel[]
pair()
int
read
(ByteBuffer dst) <T> SocketChannel
setOption
(SocketOption<T> name, T value) socket()
final Set
<SocketOption<?>> int
write
(ByteBuffer src) long
write
(ByteBuffer[] srcs, int offset, int length) 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
-
Field Details
-
state
-
remoteAddress
-
localAddress
-
stateLock
-
bindHandler
-
-
Constructor Details
-
UnixSocketChannel
UnixSocketChannel() throws IOException- Throws:
IOException
-
UnixSocketChannel
UnixSocketChannel(int fd) -
UnixSocketChannel
UnixSocketChannel(int fd, UnixSocketChannel.State initialState, boolean initialBoundState)
-
-
Method Details
-
open
- Throws:
IOException
-
open
- Throws:
IOException
-
create
- Throws:
IOException
-
pair
- Throws:
IOException
-
fromFD
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
-
doConnect
- Throws:
IOException
-
connect
- Throws:
IOException
-
isBound
boolean isBound() -
isConnected
public boolean isConnected()- Specified by:
isConnected
in classSocketChannel
-
isIdle
private boolean isIdle() -
isConnectionPending
public boolean isConnectionPending()- Specified by:
isConnectionPending
in classSocketChannel
-
finishConnect
- Specified by:
finishConnect
in classSocketChannel
- Throws:
IOException
-
getRemoteSocketAddress
-
getLocalSocketAddress
-
connect
- Specified by:
connect
in classSocketChannel
- Throws:
IOException
-
socket
- Specified by:
socket
in classSocketChannel
-
write
- Specified by:
write
in interfaceGatheringByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Overrides:
read
in classAbstractNativeSocketChannel
- Throws:
IOException
-
write
- Specified by:
write
in interfaceWritableByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
IOException
-
getRemoteAddress
- Specified by:
getRemoteAddress
in classSocketChannel
- Throws:
IOException
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceNetworkChannel
- Specified by:
getLocalAddress
in classSocketChannel
- Throws:
IOException
-
supportedOptions
-
getOption
- Throws:
IOException
-
setOption
- Specified by:
setOption
in interfaceNetworkChannel
- Specified by:
setOption
in classSocketChannel
- Throws:
IOException
-
bind
- Specified by:
bind
in interfaceNetworkChannel
- Specified by:
bind
in classSocketChannel
- Throws:
IOException
-