Class EpollDatagramChannel

  • All Implemented Interfaces:
    io.netty5.channel.Channel, io.netty5.channel.ChannelOutboundInvoker, io.netty5.channel.IoHandle, io.netty5.channel.socket.DatagramChannel, io.netty5.channel.unix.UnixChannel, io.netty5.util.AttributeMap, io.netty5.util.concurrent.FuturePromiseFactory, Comparable<io.netty5.channel.Channel>

    public final class EpollDatagramChannel
    extends io.netty5.channel.AbstractChannel<P,​SocketAddress,​SocketAddress>
    implements io.netty5.channel.socket.DatagramChannel
    DatagramChannel implementation that uses linux EPOLL Edge-Triggered Mode for maximal performance.

    Available options

    In addition to the options provided by DatagramChannel and UnixChannel, EpollDatagramChannel allows the following options in the option map:
    ChannelOption INET INET6 {@code UNIX
    {@link IntegerUnixChannelOption}XXX
    {@link RawUnixChannelOption}XXX
    {@link UnixChannelOption#SO_REUSEPORT}XXX
    {@link EpollChannelOption#IP_FREEBIND}XX-
    {@link EpollChannelOption#IP_RECVORIGDSTADDR}XX-
    {@link EpollChannelOption#MAX_DATAGRAM_PAYLOAD_SIZE}XX-
    {@link EpollChannelOption#UDP_GRO}XX-
    • Nested Class Summary

      • Nested classes/interfaces inherited from class io.netty5.channel.AbstractChannel

        io.netty5.channel.AbstractChannel.DefaultAbstractChannelPipeline, io.netty5.channel.AbstractChannel.ReadSink, io.netty5.channel.AbstractChannel.WriteSink
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean active  
      protected LinuxSocket socket  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.netty5.util.concurrent.Future<Void> block​(InetAddress multicastAddress, InetAddress sourceToBlock)  
      io.netty5.util.concurrent.Future<Void> block​(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)  
      protected static void checkResolvable​(InetSocketAddress addr)  
      protected void clearFlag​(int flag)  
      protected void doBind​(SocketAddress localAddress)  
      protected void doClearScheduledRead()  
      protected void doClose()  
      protected boolean doConnect​(SocketAddress remoteAddress, SocketAddress localAddress, io.netty5.buffer.Buffer initialData)
      Connect to the remote peer
      protected boolean doConnect0​(SocketAddress remote, io.netty5.buffer.Buffer initialData)  
      protected void doDisconnect()  
      protected boolean doFinishConnect​(SocketAddress requestedRemoteAddress)  
      protected void doRead​(boolean wasReadPendingAlready)  
      protected int doReadBytes​(io.netty5.buffer.Buffer buffer)
      Read bytes into the given Buffer and return the amount.
      protected boolean doReadNow​(io.netty5.channel.AbstractChannel.ReadSink readSink)  
      protected void doShutdown​(io.netty5.channel.ChannelShutdownDirection direction)  
      protected int doWriteBytes​(io.netty5.buffer.Buffer buf)  
      protected void doWriteNow​(io.netty5.channel.AbstractChannel.WriteSink writeSink)  
      protected long doWriteOrSendBytes​(io.netty5.buffer.Buffer data, SocketAddress remoteAddress, boolean fastOpen)
      Write bytes to the socket, with or without a remote address.
      protected io.netty5.channel.epoll.AbstractEpollChannel.ReadState epollInReady​(io.netty5.channel.AbstractChannel.ReadSink readSink)
      Called once EPOLLIN event is ready to be processed
      io.netty5.channel.unix.FileDescriptor fd()  
      protected boolean fetchLocalAddress()  
      protected Object filterOutboundMessage​(Object msg)  
      protected <T> T getExtendedOption​(io.netty5.channel.ChannelOption<T> option)  
      boolean isActive()  
      boolean isConnected()  
      protected boolean isExtendedOptionSupported​(io.netty5.channel.ChannelOption<?> option)  
      boolean isOpen()  
      static boolean isSegmentedDatagramPacketSupported()
      Returns true if SegmentedDatagramPacket is supported natively.
      boolean isShutdown​(io.netty5.channel.ChannelShutdownDirection direction)  
      protected static boolean isSoErrorZero​(io.netty5.channel.unix.Socket fd)  
      protected boolean isWriteFlushedScheduled()  
      io.netty5.util.concurrent.Future<Void> joinGroup​(InetAddress multicastAddress)  
      io.netty5.util.concurrent.Future<Void> joinGroup​(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)  
      io.netty5.util.concurrent.Future<Void> leaveGroup​(InetAddress multicastAddress)  
      io.netty5.util.concurrent.Future<Void> leaveGroup​(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)  
      protected SocketAddress localAddress0()  
      protected io.netty5.buffer.Buffer newDirectBuffer​(io.netty5.buffer.Buffer buf)
      Returns an off-heap copy of, and then closes, the given Buffer.
      protected io.netty5.buffer.Buffer newDirectBuffer​(io.netty5.util.Resource<?> holder, io.netty5.buffer.Buffer buf)
      Returns an off-heap copy of the given Buffer, and then closes the holder under the assumption that it owned (or was itself) the buffer.
      protected io.netty5.buffer.BufferAllocator readBufferAllocator()  
      protected void readLoopComplete()  
      protected io.netty5.channel.epoll.EpollRegistration registration()  
      protected SocketAddress remoteAddress0()  
      protected <T> void setExtendedOption​(io.netty5.channel.ChannelOption<T> option, T value)  
      protected void setFlag​(int flag)  
      protected void writeLoopComplete​(boolean allWritten)  
      • Methods inherited from class io.netty5.channel.AbstractChannel

        bufferAllocator, cacheAddresses, closeFuture, closeTransport, compareTo, equals, executor, finishConnect, getOption, hashCode, id, isConnectPending, isOptionSupported, isReadPending, isRegistered, isSupportingDisconnect, localAddress, newChannelPipeline, newSupportedIdentityOptionsSet, parent, pipeline, prepareToClose, readHandle, readIfIsAutoRead, readNow, remoteAddress, setOption, shutdownReadSide, toString, validateEventLoopGroup, validateFileRegion, writableBytes, writeFlushed, writeFlushedNow, writeHandle
      • Methods inherited from class io.netty5.util.DefaultAttributeMap

        attr, hasAttr
      • 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, parent, pipeline, read, 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 io.netty5.channel.IoHandle

        isRegistered
    • Field Detail

      • active

        protected volatile boolean active
    • Constructor Detail

      • EpollDatagramChannel

        public EpollDatagramChannel​(io.netty5.channel.EventLoop eventLoop)
        Create a new instance which selects the ProtocolFamily to use depending on the Operation Systems default which will be chosen.
      • EpollDatagramChannel

        public EpollDatagramChannel​(io.netty5.channel.EventLoop eventLoop,
                                    ProtocolFamily family)
        Create a new instance using the given ProtocolFamily. If null is used it will depend on the Operation Systems default which will be chosen.
      • EpollDatagramChannel

        public EpollDatagramChannel​(io.netty5.channel.EventLoop eventLoop,
                                    int fd,
                                    ProtocolFamily family)
        Create a new instance which selects the ProtocolFamily to use depending on the Operation Systems default which will be chosen.
    • Method Detail

      • isSegmentedDatagramPacketSupported

        public static boolean isSegmentedDatagramPacketSupported()
        Returns true if SegmentedDatagramPacket is supported natively.
        Returns:
        true if supported, false otherwise.
      • isActive

        public boolean isActive()
        Specified by:
        isActive in interface io.netty5.channel.Channel
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in interface io.netty5.channel.socket.DatagramChannel
      • joinGroup

        public io.netty5.util.concurrent.Future<Void> joinGroup​(InetAddress multicastAddress)
        Specified by:
        joinGroup in interface io.netty5.channel.socket.DatagramChannel
      • joinGroup

        public io.netty5.util.concurrent.Future<Void> joinGroup​(InetAddress multicastAddress,
                                                                NetworkInterface networkInterface,
                                                                InetAddress source)
        Specified by:
        joinGroup in interface io.netty5.channel.socket.DatagramChannel
      • leaveGroup

        public io.netty5.util.concurrent.Future<Void> leaveGroup​(InetAddress multicastAddress)
        Specified by:
        leaveGroup in interface io.netty5.channel.socket.DatagramChannel
      • leaveGroup

        public io.netty5.util.concurrent.Future<Void> leaveGroup​(InetAddress multicastAddress,
                                                                 NetworkInterface networkInterface,
                                                                 InetAddress source)
        Specified by:
        leaveGroup in interface io.netty5.channel.socket.DatagramChannel
      • block

        public io.netty5.util.concurrent.Future<Void> block​(InetAddress multicastAddress,
                                                            NetworkInterface networkInterface,
                                                            InetAddress sourceToBlock)
        Specified by:
        block in interface io.netty5.channel.socket.DatagramChannel
      • block

        public io.netty5.util.concurrent.Future<Void> block​(InetAddress multicastAddress,
                                                            InetAddress sourceToBlock)
        Specified by:
        block in interface io.netty5.channel.socket.DatagramChannel
      • doShutdown

        protected void doShutdown​(io.netty5.channel.ChannelShutdownDirection direction)
        Specified by:
        doShutdown in class io.netty5.channel.AbstractChannel<io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • isShutdown

        public boolean isShutdown​(io.netty5.channel.ChannelShutdownDirection direction)
        Specified by:
        isShutdown in interface io.netty5.channel.Channel
      • doWriteNow

        protected void doWriteNow​(io.netty5.channel.AbstractChannel.WriteSink writeSink)
                           throws Exception
        Specified by:
        doWriteNow in class io.netty5.channel.AbstractChannel<io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
        Throws:
        Exception
      • filterOutboundMessage

        protected Object filterOutboundMessage​(Object msg)
        Overrides:
        filterOutboundMessage in class io.netty5.channel.AbstractChannel<io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • epollInReady

        protected io.netty5.channel.epoll.AbstractEpollChannel.ReadState epollInReady​(io.netty5.channel.AbstractChannel.ReadSink readSink)
                                                                               throws Exception
        Called once EPOLLIN event is ready to be processed
        Throws:
        Exception
      • getExtendedOption

        protected <T> T getExtendedOption​(io.netty5.channel.ChannelOption<T> option)
      • setExtendedOption

        protected <T> void setExtendedOption​(io.netty5.channel.ChannelOption<T> option,
                                             T value)
      • isExtendedOptionSupported

        protected boolean isExtendedOptionSupported​(io.netty5.channel.ChannelOption<?> option)
      • fetchLocalAddress

        protected final boolean fetchLocalAddress()
      • isSoErrorZero

        protected static boolean isSoErrorZero​(io.netty5.channel.unix.Socket fd)
      • registration

        protected final io.netty5.channel.epoll.EpollRegistration registration()
      • fd

        public final io.netty5.channel.unix.FileDescriptor fd()
        Specified by:
        fd in interface io.netty5.channel.unix.UnixChannel
      • isOpen

        public final boolean isOpen()
        Specified by:
        isOpen in interface io.netty5.channel.Channel
      • doRead

        protected final void doRead​(boolean wasReadPendingAlready)
                             throws Exception
        Specified by:
        doRead in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
        Throws:
        Exception
      • newDirectBuffer

        protected final io.netty5.buffer.Buffer newDirectBuffer​(io.netty5.buffer.Buffer buf)
        Returns an off-heap copy of, and then closes, the given Buffer.
      • newDirectBuffer

        protected final io.netty5.buffer.Buffer newDirectBuffer​(io.netty5.util.Resource<?> holder,
                                                                io.netty5.buffer.Buffer buf)
        Returns an off-heap copy of the given Buffer, and then closes the holder under the assumption that it owned (or was itself) the buffer.
      • checkResolvable

        protected static void checkResolvable​(InetSocketAddress addr)
      • doReadBytes

        protected final int doReadBytes​(io.netty5.buffer.Buffer buffer)
                                 throws Exception
        Read bytes into the given Buffer and return the amount. This method does not modify the offset of the buffer.
        Throws:
        Exception
      • doWriteBytes

        protected final int doWriteBytes​(io.netty5.buffer.Buffer buf)
                                  throws Exception
        Throws:
        Exception
      • doWriteOrSendBytes

        protected final long doWriteOrSendBytes​(io.netty5.buffer.Buffer data,
                                                SocketAddress remoteAddress,
                                                boolean fastOpen)
                                         throws IOException
        Write bytes to the socket, with or without a remote address. Used for datagram and TCP client fast open writes.
        Throws:
        IOException
      • doReadNow

        protected boolean doReadNow​(io.netty5.channel.AbstractChannel.ReadSink readSink)
                             throws Exception
        Specified by:
        doReadNow in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
        Throws:
        Exception
      • readLoopComplete

        protected void readLoopComplete()
        Overrides:
        readLoopComplete in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • isWriteFlushedScheduled

        protected boolean isWriteFlushedScheduled()
        Overrides:
        isWriteFlushedScheduled in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • doFinishConnect

        protected boolean doFinishConnect​(SocketAddress requestedRemoteAddress)
                                   throws Exception
        Specified by:
        doFinishConnect in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
        Throws:
        Exception
      • localAddress0

        protected final SocketAddress localAddress0()
        Specified by:
        localAddress0 in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • remoteAddress0

        protected final SocketAddress remoteAddress0()
        Specified by:
        remoteAddress0 in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • doClearScheduledRead

        protected final void doClearScheduledRead()
        Overrides:
        doClearScheduledRead in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • writeLoopComplete

        protected void writeLoopComplete​(boolean allWritten)
        Overrides:
        writeLoopComplete in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>
      • readBufferAllocator

        protected io.netty5.buffer.BufferAllocator readBufferAllocator()
        Overrides:
        readBufferAllocator in class io.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,​SocketAddress,​SocketAddress>