Class KQueueDatagramChannel
- java.lang.Object
-
- io.netty5.util.DefaultAttributeMap
-
- io.netty5.channel.AbstractChannel<P,SocketAddress,SocketAddress>
-
- io.netty5.channel.kqueue.KQueueDatagramChannel
-
- All Implemented Interfaces:
Channel,ChannelOutboundInvoker,IoHandle,DatagramChannel,UnixChannel,AttributeMap,FuturePromiseFactory,Comparable<Channel>
@UnstableApi public final class KQueueDatagramChannel extends AbstractChannel<P,SocketAddress,SocketAddress> implements DatagramChannel
DatagramChannelimplementation that uses KQueue.Available options
In addition to the options provided byDatagramChannelandUnixChannel,KQueueDatagramChannelallows the following options in the option map:ChannelOptionINETINET6UNIXIntegerUnixChannelOptionX X X RawUnixChannelOptionX X X UnixChannelOption.SO_REUSEPORTX X -
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty5.channel.AbstractChannel
AbstractChannel.DefaultAbstractChannelPipeline
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprotected booleanreadPending
-
Constructor Summary
Constructors Constructor Description KQueueDatagramChannel(EventLoop eventLoop)KQueueDatagramChannel(EventLoop eventLoop, int fd, ProtocolFamily protocolFamily)KQueueDatagramChannel(EventLoop eventLoop, ProtocolFamily protocolFamily)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidautoReadCleared()Is called onceAbstractChannel.setAutoRead(boolean)is called withfalseandAbstractChannel.isAutoRead()wastruebefore.Future<Void>block(InetAddress multicastAddress, InetAddress sourceToBlock)Block the given sourceToBlock address for the given multicastAddress and notifies theFutureonce the operation completes.Future<Void>block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)Block the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theFutureonce the operation completes.protected static voidcheckResolvable(InetSocketAddress addr)protected voiddoBeginRead()Schedule a read operation.protected voiddoBind(SocketAddress localAddress)Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress)Connect to the remote peerprotected booleandoConnect0(SocketAddress remoteAddress, SocketAddress localAddress)protected voiddoDisconnect()Disconnect thisChannelfrom its remote peerprotected booleandoFinishConnect(SocketAddress requestedRemoteAddress)Finish a connect request.protected intdoReadBytes(Buffer buffer)Read bytes into the givenBufferand return the amount.protected voiddoShutdown(ChannelShutdownDirection direction)Shutdown one direction of theChannel.protected voiddoWrite(ChannelOutboundBuffer in)Flush the content of the given buffer to the remote peer.protected intdoWriteBytes(ChannelOutboundBuffer in, Buffer buf)FileDescriptorfd()Returns theFileDescriptorthat is used by thisChannel.protected booleanfetchLocalAddress()protected ObjectfilterOutboundMessage(Object msg)Invoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.protected <T> TgetExtendedOption(ChannelOption<T> option)Override to add support for moreChannelOptions.protected longgetMaxBytesPerGatheringWrite()booleanisActive()Returntrueif theChannelis active and so connected.booleanisConnected()Returntrueif theDatagramChannelis connected to the remote peer.protected booleanisExtendedOptionSupported(ChannelOption<?> option)Override to add support for moreChannelOptions.booleanisOpen()Returnstrueif theChannelis open and may get active laterbooleanisShutdown(ChannelShutdownDirection direction)Future<Void>joinGroup(InetAddress multicastAddress)Joins a multicast group and notifies theFutureonce the operation completes.Future<Void>joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)Joins the specified multicast group at the specified interface and notifies theFutureonce the operation completes.Future<Void>leaveGroup(InetAddress multicastAddress)Leaves a multicast group and notifies theFutureonce the operation completes.Future<Void>leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)Leave the specified multicast group at the specified interface using the specified source and notifies theFutureonce the operation completes.protected SocketAddresslocalAddress0()Returns theSocketAddresswhich is bound locally.protected BuffernewDirectBuffer(Buffer buf)Returns an off-heap copy of, and then closes, the givenBuffer.protected BuffernewDirectBuffer(Resource<?> holder, Buffer buf)Returns an off-heap copy of the givenBuffer, and then closes theholderunder the assumption that it owned (or was itself) the buffer.protected io.netty5.channel.kqueue.KQueueRegistrationregistration()protected SocketAddressremoteAddress0()Return theSocketAddresswhich theChannelis connected to.protected <T> voidsetExtendedOption(ChannelOption<T> option, T value)Override to add support for moreChannelOptions.protected voidsetMaxBytesPerGatheringWrite(long maxBytesPerGatheringWrite)voidsetSendBufferSize(int sendBufferSize)protected voidwriteFlushed()Write previous flushed messages.-
Methods inherited from class io.netty5.channel.AbstractChannel
annotateConnectException, assertEventLoop, bufferAllocator, cacheAddresses, closeForciblyTransport, closeFuture, closeIfClosed, closeTransport, compareTo, deregisterTransport, ensureOpen, equals, executor, finishConnect, fireChannelActiveIfNotActiveBefore, getMaxMessagesPerWrite, getOption, getWriteSpinCount, handleWriteError, hashCode, id, isAllowHalfClosure, isAutoRead, isConnectPending, isOptionSupported, isRegistered, localAddress, metadata, newChannelPipeline, newSupportedIdentityOptionsSet, outboundBuffer, parent, pipeline, prepareToClose, readIfIsAutoRead, recvBufAllocHandle, remoteAddress, runAfterTransportAction, safeSetFailure, safeSetSuccess, setBufferAllocator, setOption, shutdownTransport, toString, validate, validateEventLoopGroup, validateFileRegion, writableBytes
-
Methods inherited from class io.netty5.util.DefaultAttributeMap
attr, hasAttr
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface io.netty5.channel.Channel
bind, bufferAllocator, close, closeFuture, connect, connect, deregister, disconnect, executor, flush, getOption, id, isOpen, isOptionSupported, isWritable, localAddress, metadata, parent, pipeline, read, register, remoteAddress, sendOutboundEvent, setOption, shutdown, writableBytes, write, writeAndFlush
-
Methods inherited from interface io.netty5.channel.ChannelOutboundInvoker
newFailedFuture, newPromise, newSucceededFuture, newSucceededFuture
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface io.netty5.channel.IoHandle
isRegistered
-
-
-
-
Constructor Detail
-
KQueueDatagramChannel
public KQueueDatagramChannel(EventLoop eventLoop)
-
KQueueDatagramChannel
public KQueueDatagramChannel(EventLoop eventLoop, ProtocolFamily protocolFamily)
-
KQueueDatagramChannel
public KQueueDatagramChannel(EventLoop eventLoop, int fd, ProtocolFamily protocolFamily)
-
-
Method Detail
-
getExtendedOption
protected <T> T getExtendedOption(ChannelOption<T> option)
Description copied from class:AbstractChannelOverride to add support for moreChannelOptions. You need to also call {@link super} after handling the extra options.- Type Parameters:
T- the value type.- Parameters:
option- theChannelOption.- Returns:
- the value for the option
-
setExtendedOption
protected <T> void setExtendedOption(ChannelOption<T> option, T value)
Description copied from class:AbstractChannelOverride to add support for moreChannelOptions. You need to also call {@link super} after handling the extra options.- Type Parameters:
T- the value type.- Parameters:
option- theChannelOption.
-
isExtendedOptionSupported
protected boolean isExtendedOptionSupported(ChannelOption<?> option)
Description copied from class:AbstractChannelOverride to add support for moreChannelOptions. You need to also call {@link super} after handling the extra options.- Parameters:
option- theChannelOption.- Returns:
trueif supported,falseotherwise.
-
setSendBufferSize
public void setSendBufferSize(int sendBufferSize)
-
isActive
public boolean isActive()
Description copied from interface:ChannelReturntrueif theChannelis active and so connected.
-
isConnected
public boolean isConnected()
Description copied from interface:DatagramChannelReturntrueif theDatagramChannelis connected to the remote peer.- Specified by:
isConnectedin interfaceDatagramChannel
-
doBind
protected void doBind(SocketAddress localAddress) throws Exception
Description copied from class:AbstractChannelBind theChannelto theSocketAddress- Throws:
Exception
-
filterOutboundMessage
protected Object filterOutboundMessage(Object msg)
Description copied from class:AbstractChannelInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessagein classAbstractChannel<UnixChannel,SocketAddress,SocketAddress>
-
doDisconnect
protected void doDisconnect() throws ExceptionDescription copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Connect to the remote peer- Parameters:
remoteAddress- the address of the remote peer.localAddress- the local address of this channel.- Returns:
trueif the connect was completed,falseifAbstractChannel.finishConnect()will be called later again to try finishing the connect.- Throws:
Exception- thrown on error.
-
doClose
protected void doClose() throws ExceptionDescription copied from class:AbstractChannelClose theChannel- Throws:
Exception
-
joinGroup
public Future<Void> joinGroup(InetAddress multicastAddress)
Description copied from interface:DatagramChannelJoins a multicast group and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
joinGroupin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.- Returns:
- a
Futurewhich is notified once the operation completes.
-
joinGroup
public Future<Void> joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)
Description copied from interface:DatagramChannelJoins the specified multicast group at the specified interface and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
joinGroupin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.networkInterface- the interface to use.source- the source address (might benull).- Returns:
- a
Futurewhich is notified once the operation completes.
-
leaveGroup
public Future<Void> leaveGroup(InetAddress multicastAddress)
Description copied from interface:DatagramChannelLeaves a multicast group and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
leaveGroupin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.- Returns:
- a
Futurewhich is notified once the operation completes.
-
leaveGroup
public Future<Void> leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)
Description copied from interface:DatagramChannelLeave the specified multicast group at the specified interface using the specified source and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
leaveGroupin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.networkInterface- the interface to use.source- the source address (might benull).- Returns:
- a
Futurewhich is notified once the operation completes.
-
block
public Future<Void> block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)
Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
blockin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.networkInterface- the interface to use.sourceToBlock- the source address.- Returns:
- a
Futurewhich is notified once the operation completes.
-
block
public Future<Void> block(InetAddress multicastAddress, InetAddress sourceToBlock)
Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress and notifies theFutureonce the operation completes.If the underlying implementation does not support this operation it will return a
Futurewhich is failed with anUnsupportedOperationException.- Specified by:
blockin interfaceDatagramChannel- Parameters:
multicastAddress- the multicast group address.sourceToBlock- the source address.- Returns:
- a
Futurewhich is notified once the operation completes.
-
doWrite
protected void doWrite(ChannelOutboundBuffer in) throws Exception
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel<UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
doShutdown
protected void doShutdown(ChannelShutdownDirection direction)
Description copied from class:AbstractChannelShutdown one direction of theChannel.- Specified by:
doShutdownin classAbstractChannel<UnixChannel,SocketAddress,SocketAddress>- Parameters:
direction- the direction to shutdown.
-
isShutdown
public boolean isShutdown(ChannelShutdownDirection direction)
Description copied from interface:Channel- Specified by:
isShutdownin interfaceChannel
-
setMaxBytesPerGatheringWrite
protected void setMaxBytesPerGatheringWrite(long maxBytesPerGatheringWrite)
-
getMaxBytesPerGatheringWrite
protected long getMaxBytesPerGatheringWrite()
-
autoReadCleared
protected final void autoReadCleared()
Description copied from class:AbstractChannelIs called onceAbstractChannel.setAutoRead(boolean)is called withfalseandAbstractChannel.isAutoRead()wastruebefore.- Overrides:
autoReadClearedin classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>
-
registration
protected io.netty5.channel.kqueue.KQueueRegistration registration()
-
fd
public final FileDescriptor fd()
Description copied from interface:UnixChannelReturns theFileDescriptorthat is used by thisChannel.- Specified by:
fdin interfaceUnixChannel
-
isOpen
public final boolean isOpen()
Description copied from interface:ChannelReturnstrueif theChannelis open and may get active later
-
doBeginRead
protected final void doBeginRead()
Description copied from class:AbstractChannelSchedule a read operation.- Specified by:
doBeginReadin classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>
-
newDirectBuffer
protected final Buffer newDirectBuffer(Buffer buf)
Returns an off-heap copy of, and then closes, the givenBuffer.
-
newDirectBuffer
protected final Buffer newDirectBuffer(Resource<?> holder, Buffer buf)
Returns an off-heap copy of the givenBuffer, and then closes theholderunder the assumption that it owned (or was itself) the buffer.
-
checkResolvable
protected static void checkResolvable(InetSocketAddress addr)
-
doReadBytes
protected final int doReadBytes(Buffer buffer) throws Exception
Read bytes into the givenBufferand return the amount.- Throws:
Exception
-
doWriteBytes
protected final int doWriteBytes(ChannelOutboundBuffer in, Buffer buf) throws Exception
- Throws:
Exception
-
writeFlushed
protected final void writeFlushed()
Description copied from class:AbstractChannelWrite previous flushed messages.- Overrides:
writeFlushedin classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>
-
doFinishConnect
protected final boolean doFinishConnect(SocketAddress requestedRemoteAddress) throws Exception
Description copied from class:AbstractChannelFinish a connect request.- Specified by:
doFinishConnectin classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>- Parameters:
requestedRemoteAddress- the remote address of the peer.- Returns:
trueif the connect was completed,falseifAbstractChannel.finishConnect()will be called later again to try finishing the connect.- Throws:
Exception- thrown on error.
-
fetchLocalAddress
protected boolean fetchLocalAddress()
-
doConnect0
protected boolean doConnect0(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
- Throws:
Exception
-
localAddress0
protected SocketAddress localAddress0()
Description copied from class:AbstractChannelReturns theSocketAddresswhich is bound locally.- Specified by:
localAddress0in classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>
-
remoteAddress0
protected SocketAddress remoteAddress0()
Description copied from class:AbstractChannelReturn theSocketAddresswhich theChannelis connected to.- Specified by:
remoteAddress0in classAbstractChannel<P extends UnixChannel,SocketAddress,SocketAddress>
-
-