Class DynamicAddressConnectHandler

  • All Implemented Interfaces:
    io.netty5.channel.ChannelHandler

    public abstract class DynamicAddressConnectHandler
    extends Object
    implements io.netty5.channel.ChannelHandler
    ChannelHandler implementation which allows to dynamically replace the used remoteAddress and / or localAddress when making a connection attempt.

    This can be useful to for example bind to a specific NetworkInterface based on the remoteAddress.

    • Constructor Detail

      • DynamicAddressConnectHandler

        public DynamicAddressConnectHandler()
    • Method Detail

      • connect

        public final io.netty5.util.concurrent.Future<Void> connect​(io.netty5.channel.ChannelHandlerContext ctx,
                                                                    SocketAddress remoteAddress,
                                                                    SocketAddress localAddress)
        Specified by:
        connect in interface io.netty5.channel.ChannelHandler
      • localAddress

        protected SocketAddress localAddress​(SocketAddress remoteAddress,
                                             SocketAddress localAddress)
                                      throws Exception
        Returns the local SocketAddress to use for ChannelOutboundInvoker.connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress. By default, this method returns the given localAddress.
        Throws:
        Exception
      • remoteAddress

        protected SocketAddress remoteAddress​(SocketAddress remoteAddress,
                                              SocketAddress localAddress)
                                       throws Exception
        Returns the remote SocketAddress to use for ChannelOutboundInvoker.connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress. By default, this method returns the given remoteAddress.
        Throws:
        Exception