Package io.netty.bootstrap

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


            }*/

            // set the pipeline factory, which creates the pipeline for each newly created channels
            connectionlessClientBootstrap.handler(pipelineFactory);
            // bind and store channel so we can close it when stopping
            answer = connectionlessClientBootstrap.bind(new InetSocketAddress(0));
            answer.awaitUninterruptibly();
            Channel channel = answer.channel();
            allChannels.add(channel);
            // if udp connectionless sending is true we don't do a connect.
            // we just send on the channel created with bind which means
View Full Code Here


        b.group(group)
            .channel(NioDatagramChannel.class)
            .option(ChannelOption.SO_REUSEADDR, true)
            .handler(new ClusterStatusHandler());

        channel = (DatagramChannel)b.bind(bindAddress, port).sync().channel();
      } catch (InterruptedException e) {
        close();
        throw ExceptionUtil.asInterrupt(e);
      }
View Full Code Here

        InetSocketAddress hostAddress = new InetSocketAddress(configuration.getHost(), configuration.getPort());
        SubnetUtils multicastSubnet = new SubnetUtils(MULTICAST_SUBNET);

        if (multicastSubnet.getInfo().isInRange(configuration.getHost())) {
            ChannelFuture channelFuture = bootstrap.bind(hostAddress);
            channelFuture.awaitUninterruptibly();
            channel = channelFuture.channel();
            DatagramChannel datagramChannel = (DatagramChannel) channel;
            String networkInterface = configuration.getNetworkInterface() == null ? LOOPBACK_INTERFACE : configuration.getNetworkInterface();
            multicastNetworkInterface = NetworkInterface.getByName(networkInterface);
View Full Code Here

            LOG.info("ConnectionlessBootstrap joining {}:{} using network interface: {}", new Object[]{configuration.getHost(), configuration.getPort(), multicastNetworkInterface.getName()});
            datagramChannel.joinGroup(hostAddress, multicastNetworkInterface).syncUninterruptibly();
            allChannels.add(datagramChannel);
        } else {
            LOG.info("ConnectionlessBootstrap binding to {}:{}", configuration.getHost(), configuration.getPort());
            ChannelFuture channelFuture = bootstrap.bind(hostAddress);
            channelFuture.awaitUninterruptibly();
            channel = channelFuture.channel();
            allChannels.add(channel);
        }
    }
View Full Code Here

            }*/

            // set the pipeline factory, which creates the pipeline for each newly created channels
            connectionlessClientBootstrap.handler(pipelineFactory);
            // bind and store channel so we can close it when stopping
            ChannelFuture channelFuture = connectionlessClientBootstrap.bind(new InetSocketAddress(0));
            channelFuture.awaitUninterruptibly();
            Channel channel = channelFuture.channel();
            allChannels.add(channel);
            answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));

View Full Code Here

          .channel(NioDatagramChannel.class)
          .option(ChannelOption.SO_REUSEADDR, true)
          .handler(new ClusterStatusEncoder(isa));

      try {
        channel = (DatagramChannel) b.bind(new InetSocketAddress(0)).sync().channel();
        channel.joinGroup(ina, ni, null, channel.newPromise()).sync();
        channel.connect(isa).sync();
      } catch (InterruptedException e) {
        close();
        throw ExceptionUtil.asInterrupt(e);
View Full Code Here

            b.group(new NioEventLoopGroup())
             .channel(NioDatagramChannel.class)
             .option(ChannelOption.SO_BROADCAST, true)
             .handler(new QuoteOfTheMomentClientHandler());

            Channel ch = b.bind(0).sync().channel();

            // Broadcast the QOTM request to port 8080.
            ch.write(new DatagramPacket(
                    Unpooled.copiedBuffer("QOTM?", CharsetUtil.UTF_8),
                    new InetSocketAddress("255.255.255.255", port)));
View Full Code Here

            b.group(new NioEventLoopGroup())
             .channel(NioDatagramChannel.class)
             .option(ChannelOption.SO_BROADCAST, true)
             .handler(new QuoteOfTheMomentServerHandler());

            b.bind(port).sync().channel().closeFuture().await();
        } finally {
            b.shutdown();
        }
    }
View Full Code Here

                                .channel(NioDatagramChannel.class)
                                .handler(UdpListenerService.this);
                       
                        // remember folks, this is blocking.
                        log.info(String.format("Binding to %s", addr.toString()));
                        bootstrap.bind(addr).sync().channel().closeFuture().await();
                       
                    } finally {
                        group.shutdownGracefully();
                        running.set(false);
                    }
View Full Code Here

                        protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
                            System.err.println("SHOULD NOT BE GETTING MESSAGES");
                        }
                    });

            final Channel ch = bootstrap.bind(0).sync().channel();

            // we'll send the datagrams using a timer.
            TimerTask task = new TimerTask() {
                @Override
                public void run() {
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.