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 BindHandlerprivate UnixSocketAddressprivate UnixSocketAddressprivate UnixSocketChannel.Stateprivate final ReadWriteLock -
Constructor Summary
ConstructorsConstructorDescriptionUnixSocketChannel(int fd) UnixSocketChannel(int fd, UnixSocketChannel.State initialState, boolean initialBoundState) -
Method Summary
Modifier and TypeMethodDescriptionbind(SocketAddress local) booleanconnect(SocketAddress remote) booleanconnect(UnixSocketAddress remote) static final UnixSocketChannelcreate()private booleandoConnect(SockAddrUnix remote) booleanstatic final UnixSocketChannelfromFD(int fd) Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).final UnixSocketAddress<T> TgetOption(SocketOption<T> name) final UnixSocketAddress(package private) booleanisBound()booleanbooleanprivate booleanisIdle()static final UnixSocketChannelopen()static final UnixSocketChannelopen(UnixSocketAddress remote) static final UnixSocketChannel[]pair()intread(ByteBuffer dst) <T> SocketChannelsetOption(SocketOption<T> name, T value) socket()final Set<SocketOption<?>> intwrite(ByteBuffer src) longwrite(ByteBuffer[] srcs, int offset, int length) Methods inherited from class jnr.unixsocket.impl.AbstractNativeSocketChannel
getFD, implCloseSelectableChannel, implConfigureBlocking, read, setFD, shutdownInput, shutdownOutputMethods inherited from class java.nio.channels.SocketChannel
open, read, validOps, writeMethods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, registerMethods inherited from class java.nio.channels.SelectableChannel
registerMethods 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:
isConnectedin classSocketChannel
-
isIdle
private boolean isIdle() -
isConnectionPending
public boolean isConnectionPending()- Specified by:
isConnectionPendingin classSocketChannel
-
finishConnect
- Specified by:
finishConnectin classSocketChannel- Throws:
IOException
-
getRemoteSocketAddress
-
getLocalSocketAddress
-
connect
- Specified by:
connectin classSocketChannel- Throws:
IOException
-
socket
- Specified by:
socketin classSocketChannel
-
write
- Specified by:
writein interfaceGatheringByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
IOException
-
read
- Specified by:
readin interfaceReadableByteChannel- Overrides:
readin classAbstractNativeSocketChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
IOException
-
getRemoteAddress
- Specified by:
getRemoteAddressin classSocketChannel- Throws:
IOException
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceNetworkChannel- Specified by:
getLocalAddressin classSocketChannel- Throws:
IOException
-
supportedOptions
-
getOption
- Throws:
IOException
-
setOption
- Specified by:
setOptionin interfaceNetworkChannel- Specified by:
setOptionin classSocketChannel- Throws:
IOException
-
bind
- Specified by:
bindin interfaceNetworkChannel- Specified by:
bindin classSocketChannel- Throws:
IOException
-