Package org.jboss.netty.bootstrap

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


        cb.getPipeline().addFirst("handler", ch);

        Channel sc = sb.bind(new InetSocketAddress(0));
        int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();

        ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
        assertTrue(ccf.awaitUninterruptibly().isSuccess());

        Channel cc = ccf.getChannel();
        for (int i = 0; i < data.length;) {
            int length = Math.min(random.nextInt(1024 * 64), data.length - i);
View Full Code Here


                cb.getPipeline().addLast("encoder", new SpdyFrameEncoder(version));

                Channel sc = sb.bind(new InetSocketAddress(0));
                int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();

                ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
                assertTrue(ccf.awaitUninterruptibly().isSuccess());
                Channel cc = ccf.getChannel();

                sendAndWaitForFrame(cc, frame, captureHandler);
View Full Code Here

        cb.getPipeline().addLast("handler", ch);

        Channel sc = sb.bind(new InetSocketAddress(0));
        int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();

        ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
        ccf.awaitUninterruptibly();
        if (!ccf.isSuccess()) {
            sc.close().awaitUninterruptibly();
        }
        assertTrue(ccf.isSuccess());
View Full Code Here

            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(handler);
            }
        });
        ChannelFuture cf = cb.connect(addr, addr2).awaitUninterruptibly();

        assertTrue(cf.isSuccess());
        assertTrue(cf.getChannel().close().awaitUninterruptibly().isSuccess());

        assertNull(handler.await());
View Full Code Here

        // Start server
        sb.bind(addr);

        // Connect to the server
        ChannelFuture connectFuture = cb.connect(addr);
        connectFuture.awaitUninterruptibly();

        // Send a message event up the pipeline.
        Channels.fireMessageReceived(connectFuture.getChannel(), "Hello, World");
View Full Code Here

        // Start server
        sb.bind(addr);

        // Connect to the server
        ChannelFuture connectFuture = cb.connect(addr);
        connectFuture.awaitUninterruptibly();

        // Send a message event up the pipeline.
        Channels.fireMessageReceived(connectFuture.getChannel(), "Hello, World");
View Full Code Here

        cb.getPipeline().addAfter("decoder", "handler", ch);

        Channel sc = sb.bind(new InetSocketAddress(0));
        int port = ((InetSocketAddress) sc.getLocalAddress()).getPort();

        ChannelFuture ccf = cb.connect(new InetSocketAddress(TestUtil.getLocalHost(), port));
        assertTrue(ccf.awaitUninterruptibly().isSuccess());

        Channel cc = ccf.getChannel();
        for (String element : data) {
            String delimiter = random.nextBoolean() ? "\r\n" : "\n";
View Full Code Here

            System.err.println("Only HTTP(S) is supported.");
            return;
        }

        // Make the connection attempt.
        ChannelFuture channelFuture = b.connect(
                new InetSocketAddress(uri.getHost(), uri.getPort()));
        channelFuture.awaitUninterruptibly();

        // Read commands from the stdin.
        System.out.println("Enter text ('quit' to exit)");
View Full Code Here

      timer.newTimeout(new TimerTask() {
        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();
          }
View Full Code Here

            b.setOption("remoteAddress", getRemoteAddress());
            b.connect();
          } else if (bootstrap instanceof ConnectionlessBootstrap) {
            ConnectionlessBootstrap b = (ConnectionlessBootstrap) bootstrap;
            b.setOption("remoteAddress", getRemoteAddress());
            b.connect();
          }
        }
      }, delay.get(), unit);
    } catch (java.lang.IllegalStateException ex) {
      // The timer must have been stopped.
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.