Package io.netty.channel.socket.nio
Class NioDomainSocketChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
io.netty.channel.nio.AbstractNioByteChannel
io.netty.channel.socket.nio.NioDomainSocketChannel
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,DuplexChannel
,AttributeMap
,Comparable<Channel>
DuplexChannel
which uses NIO selector based implementation to support
UNIX Domain Sockets. This is only supported when using Java 16+.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
private final class
Nested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioByteChannel
AbstractNioByteChannel.NioByteUnsafe
Nested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafe
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
AbstractChannel.AbstractUnsafe
Nested classes/interfaces inherited from interface io.netty.channel.Channel
Channel.Unsafe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelConfig
private static final SelectorProvider
private boolean
private boolean
private static final InternalLogger
private static final Method
Fields inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instanceNioDomainSocketChannel
(Channel parent, SocketChannel socket) Create a new instanceNioDomainSocketChannel
(SocketChannel socket) Create a new instance using the givenSocketChannel
.NioDomainSocketChannel
(SelectorProvider provider) Create a new instance using the givenSelectorProvider
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
adjustMaxBytesPerGatheringWrite
(int attempted, int written, int oldMaxBytesPerGatheringWrite) config()
Returns the configuration of this channel.protected void
doBind
(SocketAddress localAddress) Bind theChannel
to theSocketAddress
protected void
doClose()
Close theChannel
protected boolean
doConnect
(SocketAddress remoteAddress, SocketAddress localAddress) Connect to the remote peerprotected void
Disconnect thisChannel
from its remote peerprotected void
Finish the connectprotected int
doReadBytes
(ByteBuf byteBuf) Read bytes into the givenByteBuf
and return the amount.protected void
Called when conditions justify shutting down the output portion of the channel.protected void
Flush the content of the given buffer to the remote peer.protected int
doWriteBytes
(ByteBuf buf) protected long
doWriteFileRegion
(FileRegion region) Write aFileRegion
boolean
isActive()
Returntrue
if theChannel
is active and so connected.boolean
Returnstrue
if and only if the remote peer shut down its output so that no more data is received from this channel.protected boolean
boolean
boolean
Determine if both the input and output of this channel have been shutdown.protected SocketChannel
protected SocketAddress
Returns theSocketAddress
which is bound locally.private static SocketChannel
newChannel
(SelectorProvider provider) protected AbstractNioChannel.AbstractNioUnsafe
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
parent()
Returns the parent of this channel.protected SocketAddress
Return theSocketAddress
which theChannel
is connected to.shutdown()
Will shutdown the input and output sides of this channel.shutdown
(ChannelPromise promise) Will shutdown the input and output sides of this channel.private static void
shutdownDone
(ChannelFuture shutdownOutputFuture, ChannelFuture shutdownInputFuture, ChannelPromise promise) Shutdown the input side of the channel.shutdownInput
(ChannelPromise promise) Will shutdown the input and notifyChannelPromise
.private void
private void
shutdownInput0
(ChannelPromise promise) shutdownOutput
(ChannelPromise promise) Will shutdown the output and notifyChannelPromise
.private void
shutdownOutputDone
(ChannelFuture shutdownOutputFuture, ChannelPromise promise) Methods inherited from class io.netty.channel.nio.AbstractNioByteChannel
clearOpWrite, doWrite0, filterOutboundMessage, incompleteWrite, metadata, setOpWrite
Methods inherited from class io.netty.channel.nio.AbstractNioChannel
clearReadPending, doBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafe
Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, equals, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, remoteAddress, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
Methods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttr
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
Methods inherited from interface io.netty.channel.Channel
alloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, eventLoop, flush, id, isOpen, isRegistered, isWritable, localAddress, metadata, pipeline, read, remoteAddress, unsafe
Methods inherited from interface io.netty.channel.ChannelOutboundInvoker
bind, bind, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, voidPromise, write, write, writeAndFlush, writeAndFlush
Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
logger
-
DEFAULT_SELECTOR_PROVIDER
-
OPEN_SOCKET_CHANNEL_WITH_FAMILY
-
config
-
isInputShutdown
private volatile boolean isInputShutdown -
isOutputShutdown
private volatile boolean isOutputShutdown
-
-
Constructor Details
-
NioDomainSocketChannel
public NioDomainSocketChannel()Create a new instance -
NioDomainSocketChannel
Create a new instance using the givenSelectorProvider
. -
NioDomainSocketChannel
Create a new instance using the givenSocketChannel
. -
NioDomainSocketChannel
Create a new instance- Parameters:
parent
- theChannel
which created this instance ornull
if it was created by the usersocket
- theSocketChannel
which will be used
-
-
Method Details
-
newChannel
-
parent
Description copied from interface:Channel
Returns the parent of this channel.- Specified by:
parent
in interfaceChannel
- Overrides:
parent
in classAbstractChannel
- Returns:
- the parent channel.
null
if this channel does not have a parent channel.
-
config
Description copied from interface:Channel
Returns the configuration of this channel. -
javaChannel
- Overrides:
javaChannel
in classAbstractNioChannel
-
isActive
public boolean isActive()Description copied from interface:Channel
Returntrue
if theChannel
is active and so connected. -
isOutputShutdown
public boolean isOutputShutdown()- Specified by:
isOutputShutdown
in interfaceDuplexChannel
- See Also:
-
isInputShutdown
public boolean isInputShutdown()Description copied from interface:DuplexChannel
Returnstrue
if and only if the remote peer shut down its output so that no more data is received from this channel. Note that the semantic of this method is different from that ofSocket.shutdownInput()
andSocket.isInputShutdown()
.- Specified by:
isInputShutdown
in interfaceDuplexChannel
-
isShutdown
public boolean isShutdown()Description copied from interface:DuplexChannel
Determine if both the input and output of this channel have been shutdown.- Specified by:
isShutdown
in interfaceDuplexChannel
-
doShutdownOutput
Description copied from class:AbstractChannel
Called when conditions justify shutting down the output portion of the channel. This may happen if a write operation throws an exception.- Overrides:
doShutdownOutput
in classAbstractChannel
- Throws:
Exception
-
shutdownOutput
- Specified by:
shutdownOutput
in interfaceDuplexChannel
- See Also:
-
shutdownOutput
Description copied from interface:DuplexChannel
Will shutdown the output and notifyChannelPromise
.- Specified by:
shutdownOutput
in interfaceDuplexChannel
- See Also:
-
shutdownInput
Description copied from class:AbstractNioByteChannel
Shutdown the input side of the channel.- Specified by:
shutdownInput
in interfaceDuplexChannel
- Specified by:
shutdownInput
in classAbstractNioByteChannel
- See Also:
-
isInputShutdown0
protected boolean isInputShutdown0()- Overrides:
isInputShutdown0
in classAbstractNioByteChannel
-
shutdownInput
Description copied from interface:DuplexChannel
Will shutdown the input and notifyChannelPromise
.- Specified by:
shutdownInput
in interfaceDuplexChannel
- See Also:
-
shutdown
Description copied from interface:DuplexChannel
Will shutdown the input and output sides of this channel.- Specified by:
shutdown
in interfaceDuplexChannel
- Returns:
- will be completed when both shutdown operations complete.
-
shutdown
Description copied from interface:DuplexChannel
Will shutdown the input and output sides of this channel.- Specified by:
shutdown
in interfaceDuplexChannel
- Parameters:
promise
- will be completed when both shutdown operations complete.- Returns:
- will be completed when both shutdown operations complete.
-
shutdownOutputDone
-
shutdownDone
private static void shutdownDone(ChannelFuture shutdownOutputFuture, ChannelFuture shutdownInputFuture, ChannelPromise promise) -
shutdownInput0
-
shutdownInput0
- Throws:
Exception
-
localAddress0
Description copied from class:AbstractChannel
Returns theSocketAddress
which is bound locally.- Specified by:
localAddress0
in classAbstractChannel
-
remoteAddress0
Description copied from class:AbstractChannel
Return theSocketAddress
which theChannel
is connected to.- Specified by:
remoteAddress0
in classAbstractChannel
-
doBind
Description copied from class:AbstractChannel
Bind theChannel
to theSocketAddress
- Specified by:
doBind
in classAbstractChannel
- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Description copied from class:AbstractNioChannel
Connect to the remote peer- Specified by:
doConnect
in classAbstractNioChannel
- Throws:
Exception
-
doFinishConnect
Description copied from class:AbstractNioChannel
Finish the connect- Specified by:
doFinishConnect
in classAbstractNioChannel
- Throws:
Exception
-
doDisconnect
Description copied from class:AbstractChannel
Disconnect thisChannel
from its remote peer- Specified by:
doDisconnect
in classAbstractChannel
- Throws:
Exception
-
doClose
Description copied from class:AbstractChannel
Close theChannel
- Overrides:
doClose
in classAbstractNioChannel
- Throws:
Exception
-
doReadBytes
Description copied from class:AbstractNioByteChannel
Read bytes into the givenByteBuf
and return the amount.- Specified by:
doReadBytes
in classAbstractNioByteChannel
- Throws:
Exception
-
doWriteBytes
Description copied from class:AbstractNioByteChannel
- Specified by:
doWriteBytes
in classAbstractNioByteChannel
- Parameters:
buf
- theByteBuf
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doWriteFileRegion
Description copied from class:AbstractNioByteChannel
Write aFileRegion
- Specified by:
doWriteFileRegion
in classAbstractNioByteChannel
- Parameters:
region
- theFileRegion
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
adjustMaxBytesPerGatheringWrite
private void adjustMaxBytesPerGatheringWrite(int attempted, int written, int oldMaxBytesPerGatheringWrite) -
doWrite
Description copied from class:AbstractChannel
Flush the content of the given buffer to the remote peer.- Overrides:
doWrite
in classAbstractNioByteChannel
- Throws:
Exception
-
newUnsafe
Description copied from class:AbstractChannel
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
- Overrides:
newUnsafe
in classAbstractNioByteChannel
-