public abstract class DynamicAddressConnectHandler extends ChannelOutboundHandlerAdapter
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
.
ChannelHandler.Sharable
Constructor and Description |
---|
DynamicAddressConnectHandler() |
Modifier and Type | Method and Description |
---|---|
void |
connect(ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.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
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress) based on the original remoteAddress
and localAddress . |
protected SocketAddress |
remoteAddress(SocketAddress remoteAddress,
SocketAddress localAddress)
Returns the remote
SocketAddress to use for
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress) based on the original remoteAddress
and localAddress . |
bind, close, deregister, disconnect, flush, read, write
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught, handlerAdded, handlerRemoved
public final void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
ChannelOutboundHandlerAdapter
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.connect
in interface ChannelOutboundHandler
connect
in class ChannelOutboundHandlerAdapter
ctx
- the ChannelHandlerContext
for which the connect operation is maderemoteAddress
- the SocketAddress
to which it should connectlocalAddress
- the SocketAddress
which is used as source on connectpromise
- the ChannelPromise
to notify once the operation completesprotected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
SocketAddress
to use for
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the original remoteAddress
and localAddress
.
By default, this method returns the given localAddress
.Exception
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
SocketAddress
to use for
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the original remoteAddress
and localAddress
.
By default, this method returns the given remoteAddress
.Exception
Copyright © 2008–2024 The Netty Project. All rights reserved.