Top Description Constructors Methods
io.netty.handler.address

public abstract Class DynamicAddressConnectHandler

extends ChannelOutboundHandlerAdapter
Class Inheritance
Imports
io.netty.channel.ChannelFuture, .ChannelFutureListener, .ChannelHandlerContext, .ChannelOutboundHandler, .ChannelOutboundHandlerAdapter, .ChannelPromise, java.net.NetworkInterface, .SocketAddress

ChannelOutboundHandler 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 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
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelOutboundHandlerAdapter.connect.

Implements io.netty.channel.ChannelOutboundHandler.connect.

Calls ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
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 io.netty.channel.ChannelOutboundHandlerAdapter:
bindclosederegisterdisconnectflushreadwrite

Constructor Detail

DynamicAddressConnectHandlerback to summary
public DynamicAddressConnectHandler()

Method Detail

connectback to summary
public final void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)

Overrides io.netty.channel.ChannelOutboundHandlerAdapter.connect.

Implements io.netty.channel.ChannelOutboundHandler.connect.

Doc from io.netty.channel.ChannelOutboundHandlerAdapter.connect.

Calls ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Parameters
ctx:ChannelHandlerContext

Doc from io.netty.channel.ChannelOutboundHandler.connect.

the ChannelHandlerContext for which the connect operation is made

remoteAddress:SocketAddress

Doc from io.netty.channel.ChannelOutboundHandler.connect.

the SocketAddress to which it should connect

localAddress:SocketAddress

Doc from io.netty.channel.ChannelOutboundHandler.connect.

the SocketAddress which is used as source on connect

promise:ChannelPromise

Doc from io.netty.channel.ChannelOutboundHandler.connect.

the ChannelPromise to notify 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.