Package io.netty.bootstrap

Examples of io.netty.bootstrap.Bootstrap.connect()


            this.active = true;
        }

        try {
            // Start the client.
            ChannelFuture f = b.connect(host, port).sync();
            // Wait until the connection is closed.
            f.channel().closeFuture().sync();
            this.failedRequests = 0;
            this.lastSuccessfulRequest = System.currentTimeMillis() / 1000;
        } catch (Exception e) {
View Full Code Here


                            pipeline.addLast("aggregator", new HttpObjectAggregator(8192));
                            pipeline.addLast("ws-handler", handler);
                        }
                    });

            final Channel ch = b.connect(uri.getHost(), uri.getPort()).sync().channel();
            handler.handshakeFuture().sync();

            final String uaid = UUIDUtil.newUAID();
            final String json = JsonUtil.toJson(new HelloMessageImpl(uaid.toString()));
            final ChannelFuture future = ch.writeAndFlush(new TextWebSocketFrame(json));
View Full Code Here

                    pipeline.addLast("aggregator", new HttpObjectAggregator(8192));
                    pipeline.addLast("ws-handler", handler);
                }
            });

            final Channel ch = b.connect(uri.getHost(), uri.getPort()).sync().channel();
            handler.handshakeFuture().sync();

            final String uaid = UUIDUtil.newUAID();
            final String json = JsonUtil.toJson(new HelloMessageImpl(uaid.toString()));
            final ChannelFuture future = ch.writeAndFlush(new TextWebSocketFrame(json));
View Full Code Here

                        }
                    }
            );

            // Start the client.
            ChannelFuture f = b.connect().sync();

            // Wait until the connection is closed.
            f.channel().closeFuture().sync();
            logger.debug("Connection is closed");
View Full Code Here

            b.remoteAddress(host, port);
           
            b.handler(ethereumChannelInitializer);

            // Start the client.
            ChannelFuture f = b.connect().sync();

            // Wait until the connection is closed.
            f.channel().closeFuture().sync();
            logger.debug("Connection is closed");
View Full Code Here

      }
    });

    // Connect to the remote server
    long preConnect = System.currentTimeMillis();
    ChannelFuture cf = bootstrap.connect(address);
    if (!cf.awaitUninterruptibly(conf.connectionTimeoutMs())) {
      throw new IOException(
        String.format("Connecting to %s timed out (%s ms)", address, conf.connectionTimeoutMs()));
    } else if (cf.cause() != null) {
      throw new IOException(String.format("Failed to connect to %s", address), cf.cause());
View Full Code Here

              }
            });
          }
        });

      ChannelFuture connectFuture = b.connect(host, port);
      connectFuture.addListener(f1 -> {
        if (connectFuture.isSuccess()) {

          String fullPath = getFullPath(uri);
          FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(requestSpecBacking.getMethod()), fullPath, requestSpecBacking.getBody());
View Full Code Here

                        byteBuf.clear();
                    }
                });
        bootstrap.option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000);

        ChannelFuture future = bootstrap.connect(new InetSocketAddress("www.manning.com", 80));
        future.syncUninterruptibly();
    }
}
View Full Code Here

                    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
                        System.out.println("Reveived data");
                        byteBuf.clear();
                    }
                });
        ChannelFuture future = bootstrap.connect(new InetSocketAddress("www.manning.com", 80));
        future.syncUninterruptibly();
    }

    public static void main(String args[]) {
        InvalidBootstrapClient client = new InvalidBootstrapClient();
View Full Code Here

                    @Override
                    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) throws Exception {
                        ctx.deregister();
                    }
                });
        ChannelFuture future = bootstrap.connect(new InetSocketAddress("www.manning.com", 80));
        future.addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                if (channelFuture.isSuccess()) {
                    System.out.println("Connection established");
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.