Package org.jboss.netty.bootstrap

Examples of org.jboss.netty.bootstrap.ClientBootstrap.connect()


  private Channel connect(final SocketAddress address, final ChannelHandler codec,
                          final ChannelHandler handler) {
    final ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory());
    bootstrap.setPipeline(Channels.pipeline(codec, handler));
    return bootstrap.connect(address).getChannel();
  }

  public void testRequestReply(final ChannelHandler serverCodec, final ChannelHandler clientCodec)
      throws InterruptedException {
View Full Code Here


      @Override
      public ChannelPipeline getPipeline() throws Exception {
        return Channels.pipeline(new SimpleChannelUpstreamHandler());
      }
    });
    final ChannelFuture future = clientBootstrap.connect(serverAddress);
    future.awaitUninterruptibly();

    final Channel channel = future.getChannel();

    final StringBuilder payload = new StringBuilder();
View Full Code Here

                }
            }

            // set the pipeline factory, which creates the pipeline for each newly created channels
            clientBootstrap.setPipelineFactory(pipelineFactory);
            answer = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            if (LOG.isDebugEnabled()) {
                LOG.debug("Created new TCP client bootstrap connecting to {}:{} with options: {}",
                        new Object[]{configuration.getHost(), configuration.getPort(), clientBootstrap.getOptions()});
            }
            return answer;
View Full Code Here

        ClientBootstrap bootstrap = new ClientBootstrap(channelFactory);
        bootstrap.setPipelineFactory(this);
        bootstrap.setOption("tcpNoDelay", conf.getClientTcpNoDelay());
        bootstrap.setOption("keepAlive", true);

        ChannelFuture future = bootstrap.connect(addr);

        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                int rc;
View Full Code Here

        cb.setOption("connectTimeMillis", this.connectTime);
        // outbound handler gets no link to channel group because these two connections act as one: if one goes down, it
        // takes the other end with it.
        cb.getPipeline().addLast("handler", new TcpTunnelOutboundHandler(this.id, this.remoteHost, this.remotePort,
                                                                         e.getChannel()));
        ChannelFuture f = cb.connect(new InetSocketAddress(this.remoteHost, this.remotePort));

        this.outboundChannel = f.getChannel();
        f.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {
                if (future.isSuccess()) {
View Full Code Here

        queueFactory,isDebugOn,
        senderCompID,
        targetCompID,
        outgoingCallback,
        ObjectArrays.concat(channelHandlers, new MessageBroadcaster(listeners))));
    final ChannelFuture channelFut = client.connect(new InetSocketAddress(remoteAddress, remotePort));
   
    channelFut.addListener(new ChannelFutureListener() {
     

      @Override
View Full Code Here

    inboundChannel.setReadable(false);

    // Start the connection attempt.
    ClientBootstrap cb = new ClientBootstrap(cf);
    cb.getPipeline().addLast("handler", new OutboundHandler(e.getChannel()));
    ChannelFuture f = cb.connect(new InetSocketAddress(remoteHost, remotePort));

    outboundChannel = f.getChannel();
    f.addListener(new ChannelFutureListener() {
      public void operationComplete(ChannelFuture future) throws Exception {
        if (future.isSuccess()) {
View Full Code Here

    inboundChannel.setReadable(false);

    // Start the connection attempt.
    ClientBootstrap cb = new ClientBootstrap(cf);
    cb.getPipeline().addLast("handler", new OutboundHandler(e.getChannel()));
    ChannelFuture f = cb.connect(new InetSocketAddress(remoteHost, remotePort));
    f.await(); // avoids writing before channel connect is completed
    outboundChannel = f.getChannel();
    f.addListener(new ChannelFutureListener() {
      public void operationComplete(ChannelFuture future) throws Exception {
        if (future.isSuccess()) {
View Full Code Here

            clientBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
            clientBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());

            // set the pipeline on the bootstrap
            clientBootstrap.setPipeline(clientPipeline);
            answer = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
            return answer;
        } else {
            ConnectionlessBootstrap connectionlessClientBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
            connectionlessClientBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
            connectionlessClientBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
View Full Code Here

        // Configure the event pipeline factory.
        bootstrap.setPipelineFactory(new LocalTimeClientPipelineFactory());

        // Make a new connection.
        ChannelFuture connectFuture =
            bootstrap.connect(new InetSocketAddress(host, port));

        // Wait until the connection is made successfully.
        Channel channel = connectFuture.awaitUninterruptibly().getChannel();

        // Get the handler instance to initiate the request.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.