Top Description Constructors Methods
io.netty5.handler.address

public abstract Class DynamicAddressConnectHandler

extends Object
implements ChannelHandler
Class Inheritance
All Implemented Interfaces
io.netty5.channel.ChannelHandler
Imports
io.netty5.channel.ChannelHandler, .ChannelHandlerContext, io.netty5.util.concurrent.Future, java.net.NetworkInterface, .SocketAddress

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 Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final Future<Void>
connect(ChannelHandlerContext
the ChannelHandlerContext for which the connect operation is made
ctx
,
SocketAddress
the SocketAddress to which it should connect
remoteAddress
,
SocketAddress
the SocketAddress which is used as source on connect
localAddress
)

Overrides default io.netty5.channel.ChannelHandler.connect.

Called once a connect operation is made.
protected SocketAddress
localAddress(SocketAddress remoteAddress, SocketAddress localAddress)

Returns the local SocketAddress to use for ChannelHandlerContext#connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress.

protected SocketAddress
remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress)

Returns the remote SocketAddress to use for ChannelHandlerContext#connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DynamicAddressConnectHandlerback to summary
public DynamicAddressConnectHandler()

Method Detail

connectback to summary
public final Future<Void> connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)

Overrides default io.netty5.channel.ChannelHandler.connect.

Doc from io.netty5.channel.ChannelHandler.connect.

Called once a connect operation is made.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext for which the connect operation is made

remoteAddress:SocketAddress

the SocketAddress to which it should connect

localAddress:SocketAddress

the SocketAddress which is used as source on connect

Returns:Future<Void>

the Future which will be notified once the operation completes.

Annotations
@Override
localAddressback to summary
protected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception

Returns the local SocketAddress to use for ChannelHandlerContext#connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress. By default, this method returns the given localAddress.

remoteAddressback to summary
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception

Returns the remote SocketAddress to use for ChannelHandlerContext#connect(SocketAddress, SocketAddress) based on the original remoteAddress and localAddress. By default, this method returns the given remoteAddress.