Package io.netty.bootstrap
Class Bootstrap
- java.lang.Object
-
- io.netty.bootstrap.AbstractBootstrap<Bootstrap,Channel>
-
- io.netty.bootstrap.Bootstrap
-
- All Implemented Interfaces:
java.lang.Cloneable
public class Bootstrap extends AbstractBootstrap<Bootstrap,Channel>
ABootstrap
that makes it easy to bootstrap aChannel
to use for clients.The
AbstractBootstrap.bind()
methods are useful in combination with connectionless transports such as datagram (UDP). For regular TCP connections, please use the providedconnect()
methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Bootstrap.ExternalAddressResolver
-
Nested classes/interfaces inherited from class io.netty.bootstrap.AbstractBootstrap
AbstractBootstrap.PendingRegistrationPromise
-
-
Field Summary
Fields Modifier and Type Field Description private BootstrapConfig
config
private boolean
disableResolver
private Bootstrap.ExternalAddressResolver
externalResolver
private static InternalLogger
logger
private java.net.SocketAddress
remoteAddress
-
Fields inherited from class io.netty.bootstrap.AbstractBootstrap
group
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Bootstrap
clone()
Returns a deep clone of this bootstrap which has the identical configuration.Bootstrap
clone(EventLoopGroup group)
Returns a deep clone of this bootstrap which has the identical configuration except that it uses the givenEventLoopGroup
.BootstrapConfig
config()
Returns theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap.ChannelFuture
connect()
Connect aChannel
to the remote peer.ChannelFuture
connect(java.lang.String inetHost, int inetPort)
Connect aChannel
to the remote peer.ChannelFuture
connect(java.net.InetAddress inetHost, int inetPort)
Connect aChannel
to the remote peer.ChannelFuture
connect(java.net.SocketAddress remoteAddress)
Connect aChannel
to the remote peer.ChannelFuture
connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Connect aChannel
to the remote peer.Bootstrap
disableResolver()
Disables address name resolution.private static void
doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise connectPromise)
private ChannelFuture
doResolveAndConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
private ChannelFuture
doResolveAndConnect0(Channel channel, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
(package private) void
init(Channel channel)
(package private) java.net.SocketAddress
remoteAddress()
Bootstrap
remoteAddress(java.lang.String inetHost, int inetPort)
Bootstrap
remoteAddress(java.net.InetAddress inetHost, int inetPort)
Bootstrap
remoteAddress(java.net.SocketAddress remoteAddress)
TheSocketAddress
to connect to once theconnect()
method is called.(package private) AddressResolverGroup<?>
resolver()
Bootstrap
resolver(AddressResolverGroup<?> resolver)
Sets theNameResolver
which will resolve the address of the unresolved named address.Bootstrap
validate()
Validate all the parameters.-
Methods inherited from class io.netty.bootstrap.AbstractBootstrap
attr, attrs, attrs0, bind, bind, bind, bind, bind, channel, channelFactory, channelFactory, channelFactory, copiedMap, extensionsClassLoader, getInitializerExtensions, group, group, handler, handler, initAndRegister, localAddress, localAddress, localAddress, localAddress, localAddress, newAttributesArray, newAttributesArray, newOptionsArray, newOptionsArray, option, options, options0, register, setAttributes, setChannelOptions, toString
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
config
private final BootstrapConfig config
-
externalResolver
private Bootstrap.ExternalAddressResolver externalResolver
-
disableResolver
private volatile boolean disableResolver
-
remoteAddress
private volatile java.net.SocketAddress remoteAddress
-
-
Constructor Detail
-
Bootstrap
public Bootstrap()
-
Bootstrap
private Bootstrap(Bootstrap bootstrap)
-
-
Method Detail
-
resolver
public Bootstrap resolver(AddressResolverGroup<?> resolver)
Sets theNameResolver
which will resolve the address of the unresolved named address.- Parameters:
resolver
- theNameResolver
for thisBootstrap
; may benull
, in which case a default resolver will be used- See Also:
DefaultAddressResolverGroup
-
disableResolver
public Bootstrap disableResolver()
Disables address name resolution. Name resolution may be re-enabled withresolver(AddressResolverGroup)
-
remoteAddress
public Bootstrap remoteAddress(java.net.SocketAddress remoteAddress)
TheSocketAddress
to connect to once theconnect()
method is called.
-
remoteAddress
public Bootstrap remoteAddress(java.lang.String inetHost, int inetPort)
- See Also:
remoteAddress(SocketAddress)
-
remoteAddress
public Bootstrap remoteAddress(java.net.InetAddress inetHost, int inetPort)
- See Also:
remoteAddress(SocketAddress)
-
connect
public ChannelFuture connect()
Connect aChannel
to the remote peer.
-
connect
public ChannelFuture connect(java.lang.String inetHost, int inetPort)
Connect aChannel
to the remote peer.
-
connect
public ChannelFuture connect(java.net.InetAddress inetHost, int inetPort)
Connect aChannel
to the remote peer.
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
Connect aChannel
to the remote peer.
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Connect aChannel
to the remote peer.
-
doResolveAndConnect
private ChannelFuture doResolveAndConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
- See Also:
connect()
-
doResolveAndConnect0
private ChannelFuture doResolveAndConnect0(Channel channel, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
-
doConnect
private static void doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise connectPromise)
-
init
void init(Channel channel)
- Specified by:
init
in classAbstractBootstrap<Bootstrap,Channel>
-
validate
public Bootstrap validate()
Description copied from class:AbstractBootstrap
Validate all the parameters. Sub-classes may override this, but should call the super method in that case.- Overrides:
validate
in classAbstractBootstrap<Bootstrap,Channel>
-
clone
public Bootstrap clone()
Description copied from class:AbstractBootstrap
Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making multipleChannel
s with similar settings. Please note that this method does not clone theEventLoopGroup
deeply but shallowly, making the group a shared resource.- Specified by:
clone
in classAbstractBootstrap<Bootstrap,Channel>
-
clone
public Bootstrap clone(EventLoopGroup group)
Returns a deep clone of this bootstrap which has the identical configuration except that it uses the givenEventLoopGroup
. This method is useful when making multipleChannel
s with similar settings.
-
config
public final BootstrapConfig config()
Description copied from class:AbstractBootstrap
Returns theAbstractBootstrapConfig
object that can be used to obtain the current config of the bootstrap.- Specified by:
config
in classAbstractBootstrap<Bootstrap,Channel>
-
remoteAddress
final java.net.SocketAddress remoteAddress()
-
resolver
final AddressResolverGroup<?> resolver()
-
-