public abstract class DynamicAddressConnectHandler
extends io.netty.channel.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
.
Constructor and Description |
---|
DynamicAddressConnectHandler() |
Modifier and Type | Method and Description |
---|---|
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
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
public final void connect(io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, io.netty.channel.ChannelPromise promise)
connect
in interface io.netty.channel.ChannelOutboundHandler
connect
in class io.netty.channel.ChannelOutboundHandlerAdapter
protected 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–2019 The Netty Project. All rights reserved.