/** * Creates a new connected channel with the specified * {@code "remoteAddress"} and the current {@code "localAddress"} option. * If the {@code "localAddress"} option is not set, the local address of * a new channel is determined automatically. This method is identical * with the following code: * * <pre> * {@link ConnectionlessBootstrap} b = ...; * b.connect(remoteAddress, b.getOption("localAddress")); * </pre> * * @return a future object which notifies when the creation of the connected * channel succeeds or fails * * @throws ClassCastException * if {@code "localAddress"} option's value is * neither a {@link SocketAddress} nor {@code null} * @throws ChannelPipelineException * if this bootstrap's {@link #setPipelineFactory(ChannelPipelineFactory) pipelineFactory} * failed to create a new {@link ChannelPipeline} */ public ChannelFuture connect(SocketAddress remoteAddress) { if (remoteAddress == null) { throw new NullPointerException("remotedAddress"); } SocketAddress localAddress = (SocketAddress) getOption("localAddress"); return connect(remoteAddress, localAddress); }
/** * Creates a new connected channel with the current {@code "remoteAddress"} * and {@code "localAddress"} option. If the {@code "localAddress"} option * is not set, the local address of a new channel is determined * automatically. This method is similar to the following code: * * <pre> * {@link ConnectionlessBootstrap} b = ...; * b.connect(b.getOption("remoteAddress"), b.getOption("localAddress")); * </pre> * * @return a future object which notifies when the creation of the connected * channel succeeds or fails * * @throws IllegalStateException * if {@code "remoteAddress"} option was not set * @throws ClassCastException * if {@code "remoteAddress"} or {@code "localAddress"} option's * value is neither a {@link SocketAddress} nor {@code null} * @throws ChannelPipelineException * if this bootstrap's {@link #setPipelineFactory(ChannelPipelineFactory) pipelineFactory} * failed to create a new {@link ChannelPipeline} */ public ChannelFuture connect() { SocketAddress remoteAddress = (SocketAddress) getOption("remoteAddress"); if (remoteAddress == null) { throw new IllegalStateException("remoteAddress option is not set."); } return connect(remoteAddress); }
.connect(new InetSocketAddress(targetHost, udpMeta.getUdpPort()));
public void run(Timeout timeout) throws Exception { if (bootstrap instanceof ClientBootstrap) { ClientBootstrap b = (ClientBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } else if (bootstrap instanceof ConnectionlessBootstrap) { ConnectionlessBootstrap b = (ConnectionlessBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } } }, delay.get(), unit);
final ChannelFuture result = bootstrap.connect().awaitUninterruptibly();
answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort())); } else {
.connect(new InetSocketAddress(targetHost, udpMeta.getUdpPort()));