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 classes/interfaces inherited from class AbstractNioByteChannel
AbstractNioByteChannel.NioByteUnsafeNested classes/interfaces inherited from class AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeModifier and TypeClassDescriptionprotected classstatic interfaceSpecialChannel.Unsafesub-type which allows to access the underlyingSelectableChannelNested classes/interfaces inherited from class AbstractChannel
AbstractChannel.AbstractUnsafeModifier and TypeClassDescriptionprotected classChannel.Unsafeimplementation which sub-classes must extend and use.Nested classes/interfaces inherited from interface Channel
Channel.UnsafeModifier and TypeInterfaceDescriptionstatic interfaceUnsafe operations that should never be called from user-code. -
Field Summary
Fields inherited from class AbstractNioChannel
readInterestOp, readOps -
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 TypeMethodDescriptionconfig()Returns the configuration of this channel.protected voiddoBind(SocketAddress localAddress) Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress) Connect to the remote peerprotected voidDisconnect thisChannelfrom its remote peerprotected voidFinish the connectprotected intdoReadBytes(ByteBuf byteBuf) Read bytes into the givenByteBufand return the amount.protected voidCalled when conditions justify shutting down the output portion of the channel.protected voidFlush the content of the given buffer to the remote peer.protected intdoWriteBytes(ByteBuf buf) protected longdoWriteFileRegion(FileRegion region) Write aFileRegionbooleanisActive()Returntrueif theChannelis active and so connected.booleanReturnstrueif and only if the remote peer shut down its output so that no more data is received from this channel.protected booleanbooleanbooleanDetermine if both the input and output of this channel have been shutdown.protected SocketChannelprotected SocketAddressReturns theSocketAddresswhich is bound locally.protected AbstractNioChannel.AbstractNioUnsafeCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelparent()Returns the parent of this channel.protected SocketAddressReturn theSocketAddresswhich theChannelis 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.Shutdown the input side of the channel.shutdownInput(ChannelPromise promise) Will shutdown the input and notifyChannelPromise.shutdownOutput(ChannelPromise promise) Will shutdown the output and notifyChannelPromise.Methods inherited from class AbstractNioByteChannel
clearOpWrite, doWrite0, filterOutboundMessage, incompleteWrite, metadata, setOpWriteModifier and TypeMethodDescriptionprotected final voidprotected final intWrite objects to the OS.protected final ObjectInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.protected final voidincompleteWrite(boolean setOpWrite) metadata()protected final voidMethods inherited from class AbstractNioChannel
addAndSubmit, clearReadPending, doBeginRead, doDeregister, doRegister, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, registration, removeAndSubmit, selectionKey, setReadPending, unsafeModifier and TypeMethodDescriptionprotected voidaddAndSubmit(NioIoOps addOps) protected final voidSet read pending tofalse.protected voidSchedule a read operation.protected voidprotected voiddoRegister(ChannelPromise promise) protected booleanisCompatible(EventLoop loop) Returntrueif the givenEventLoopis compatible with this instance.booleanisOpen()Returnstrueif theChannelis open and may get active laterprotected booleanDeprecated.No longer supported.protected final ByteBufnewDirectBuffer(ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the original one.protected final ByteBufnewDirectBuffer(ReferenceCounted holder, ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder.protected IoRegistrationprotected voidremoveAndSubmit(NioIoOps removeOps) protected SelectionKeyDeprecated.useAbstractNioChannel.registration.protected voidsetReadPending(boolean readPending) Deprecated.UseAbstractNioChannel.clearReadPending()if appropriate instead.unsafe()Returns an internal-use-only object that provides unsafe operations.Methods inherited from class AbstractChannel
closeFuture, compareTo, doRegister, equals, eventLoop, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, maxMessagesPerWrite, newChannelPipeline, newId, pipeline, remoteAddress, toString, validateFileRegion, voidPromiseModifier and TypeMethodDescriptionReturns theChannelFuturewhich will be notified when this channel is closed.final intprotected voidDeprecated.final booleanReturnstrueif and only if the specified object is identical with this channel (i.e:this == o).final inthashCode()Returns the ID of this channel.final ChannelIdid()Returns the globally unique identifier of thisChannel.protected voidDeprecated.no use-case for this.protected voidDeprecated.no use-case for this.booleanReturns the local address where this channel is bound to.protected final intprotected DefaultChannelPipelineReturns a newDefaultChannelPipelineinstance.protected ChannelIdnewId()Returns a newDefaultChannelIdinstance.pipeline()Return the assignedChannelPipeline.Returns the remote address where this channel is connected to.toString()Returns theStringrepresentation of this channel.protected voidvalidateFileRegion(DefaultFileRegion region, long position) final ChannelPromiseReturn a special ChannelPromise which can be reused for different operations.Methods inherited from class DefaultAttributeMap
attr, hasAttrModifier and TypeMethodDescription<T> Attribute<T> attr(AttributeKey<T> key) Get theAttributefor the givenAttributeKey.<T> booleanhasAttr(AttributeKey<T> key) Methods inherited from interface Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, flush, getOption, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, read, setOption, write, write, writeAndFlush, writeAndFlushModifier and TypeMethodDescriptiondefault ByteBufAllocatoralloc()Return the assignedByteBufAllocatorwhich will be used to allocateByteBufs.default ChannelFuturebind(SocketAddress localAddress) Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturebind(SocketAddress localAddress, ChannelPromise promise) Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default longGet how many bytes can be written untilChannel.isWritable()returnsfalse.default longGet how many bytes must be drained from underlying buffers untilChannel.isWritable()returnstrue.default ChannelFutureclose()Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureclose(ChannelPromise promise) Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress) Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, ChannelPromise promise) Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, SocketAddress localAddress) Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureRequest to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturederegister(ChannelPromise promise) Request to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureRequest to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturedisconnect(ChannelPromise promise) Request to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default Channelflush()Request to flush all pending messages via this ChannelOutboundInvoker.default <T> TgetOption(ChannelOption<T> option) Return the value of the givenChannelOptiondefault booleanReturnstrueif and only if the I/O thread will perform the requested write operation immediately.default ChannelFuturenewFailedFuture(Throwable cause) Create a newChannelFuturewhich is marked as failed already.default ChannelProgressivePromiseReturn an newChannelProgressivePromisedefault ChannelPromiseReturn a newChannelPromise.default ChannelFutureCreate a newChannelFuturewhich is marked as succeeded already.default Channelread()Request to Read data from theChannelinto the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)event if data was read, and triggers achannelReadCompleteevent so the handler can decide to continue reading.default <T> booleansetOption(ChannelOption<T> option, T value) Sets a configuration property with the specified name and value.default ChannelFutureRequest to write a message via thisChannelHandlerContextthrough theChannelPipeline.default ChannelFuturewrite(Object msg, ChannelPromise promise) Request to write a message via thisChannelHandlerContextthrough theChannelPipeline.default ChannelFuturewriteAndFlush(Object msg) Shortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().default ChannelFuturewriteAndFlush(Object msg, ChannelPromise promise) Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)andChannelOutboundInvoker.flush().
-
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- theChannelwhich created this instance ornullif it was created by the usersocket- theSocketChannelwhich will be used
-
-
Method Details
-
parent
Description copied from interface:ChannelReturns the parent of this channel.- Specified by:
parentin interfaceChannel- Overrides:
parentin classAbstractChannel- Returns:
- the parent channel.
nullif this channel does not have a parent channel.
-
config
Description copied from interface:ChannelReturns the configuration of this channel. -
javaChannel
- Overrides:
javaChannelin classAbstractNioChannel
-
isActive
-
isOutputShutdown
public boolean isOutputShutdown()- Specified by:
isOutputShutdownin interfaceDuplexChannel- See Also:
-
isInputShutdown
public boolean isInputShutdown()Description copied from interface:DuplexChannelReturnstrueif 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:
isInputShutdownin interfaceDuplexChannel
-
isShutdown
public boolean isShutdown()Description copied from interface:DuplexChannelDetermine if both the input and output of this channel have been shutdown.- Specified by:
isShutdownin interfaceDuplexChannel
-
doShutdownOutput
Description copied from class:AbstractChannelCalled when conditions justify shutting down the output portion of the channel. This may happen if a write operation throws an exception.- Overrides:
doShutdownOutputin classAbstractChannel- Throws:
Exception
-
shutdownOutput
- Specified by:
shutdownOutputin interfaceDuplexChannel- See Also:
-
shutdownOutput
Description copied from interface:DuplexChannelWill shutdown the output and notifyChannelPromise.- Specified by:
shutdownOutputin interfaceDuplexChannel- See Also:
-
shutdownInput
Description copied from class:AbstractNioByteChannelShutdown the input side of the channel.- Specified by:
shutdownInputin interfaceDuplexChannel- Specified by:
shutdownInputin classAbstractNioByteChannel- See Also:
-
isInputShutdown0
protected boolean isInputShutdown0()- Overrides:
isInputShutdown0in classAbstractNioByteChannel
-
shutdownInput
Description copied from interface:DuplexChannelWill shutdown the input and notifyChannelPromise.- Specified by:
shutdownInputin interfaceDuplexChannel- See Also:
-
shutdown
Description copied from interface:DuplexChannelWill shutdown the input and output sides of this channel.- Specified by:
shutdownin interfaceDuplexChannel- Returns:
- will be completed when both shutdown operations complete.
-
shutdown
Description copied from interface:DuplexChannelWill shutdown the input and output sides of this channel.- Specified by:
shutdownin interfaceDuplexChannel- Parameters:
promise- will be completed when both shutdown operations complete.- Returns:
- will be completed when both shutdown operations complete.
-
localAddress0
Description copied from class:AbstractChannelReturns theSocketAddresswhich is bound locally.- Specified by:
localAddress0in classAbstractChannel
-
remoteAddress0
Description copied from class:AbstractChannelReturn theSocketAddresswhich theChannelis connected to.- Specified by:
remoteAddress0in classAbstractChannel
-
doBind
Description copied from class:AbstractChannelBind theChannelto theSocketAddress- Specified by:
doBindin classAbstractChannel- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Description copied from class:AbstractNioChannelConnect to the remote peer- Specified by:
doConnectin classAbstractNioChannel- Throws:
Exception
-
doFinishConnect
Description copied from class:AbstractNioChannelFinish the connect- Specified by:
doFinishConnectin classAbstractNioChannel- Throws:
Exception
-
doDisconnect
Description copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Specified by:
doDisconnectin classAbstractChannel- Throws:
Exception
-
doClose
Description copied from class:AbstractChannelClose theChannel- Overrides:
doClosein classAbstractNioChannel- Throws:
Exception
-
doReadBytes
Description copied from class:AbstractNioByteChannelRead bytes into the givenByteBufand return the amount.- Specified by:
doReadBytesin classAbstractNioByteChannel- Throws:
Exception
-
doWriteBytes
Description copied from class:AbstractNioByteChannel- Specified by:
doWriteBytesin classAbstractNioByteChannel- Parameters:
buf- theByteBuffrom which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doWriteFileRegion
Description copied from class:AbstractNioByteChannelWrite aFileRegion- Specified by:
doWriteFileRegionin classAbstractNioByteChannel- Parameters:
region- theFileRegionfrom which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doWrite
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Overrides:
doWritein classAbstractNioByteChannel- Throws:
Exception
-
newUnsafe
Description copied from class:AbstractChannelCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel- Overrides:
newUnsafein classAbstractNioByteChannel
-