Examples of NioDatagramChannel


Examples of io.netty.channel.socket.nio.NioDatagramChannel

            bootstrap.option(ChannelOption.SO_REUSEADDR, flags != 0);
            bootstrap.channelFactory( new ChannelFactory<Channel>() {
                @Override
                public Channel newChannel() {
                    return new NioDatagramChannel( family == Family.IPv4 ? InternetProtocolFamily.IPv4 : InternetProtocolFamily.IPv6 );
                }
            });
            this.channelFuture = bootstrap.localAddress(localAddress).bind();
            this.channelFuture.sync();
        } catch (Exception e) {
View Full Code Here

Examples of io.netty.channel.socket.nio.NioDatagramChannel

        .option(ChannelOption.SO_SNDBUF, options.sndbuf())
        .option(ChannelOption.SO_REUSEADDR, options.reuseAddr())
        .channelFactory(new ChannelFactory<Channel>() {
          @Override
          public Channel newChannel() {
            final NioDatagramChannel ch = new NioDatagramChannel();
            DatagramChannelConfig config = ch.config();
            config.setReceiveBufferSize(options.rcvbuf());
            config.setSendBufferSize(options.sndbuf());
            config.setReuseAddress(options.reuseAddr());

            if (null != multicastInterface) {
              config.setNetworkInterface(multicastInterface);
            }

            if (null != nettyOptions && null != nettyOptions.pipelineConfigurer()) {
              nettyOptions.pipelineConfigurer().accept(ch.pipeline());
            }

            ch.closeFuture().addListener(new ChannelFutureListener() {
              @Override
              public void operationComplete(ChannelFuture future) throws Exception {
                if (log.isInfoEnabled()) {
                  log.info("CLOSE {}", ch);
                }
                close(ch);
              }
            });

            netChannel = (NettyNetChannel<IN, OUT>) select(ch);
            inboundHandler.setNetChannel(netChannel);

            ch.pipeline().addLast(new ChannelOutboundHandlerAdapter() {
              @Override
              public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
                super.write(ctx, msg, promise);
              }
            });
View Full Code Here

Examples of io.netty.channel.socket.nio.NioDatagramChannel

    return (DatagramChannel) channel;
  }

  private static NioDatagramChannel createChannel(io.vertx.core.datagram.impl.InternetProtocolFamily family,
                                                  DatagramSocketOptions options) {
    NioDatagramChannel channel;
    if (family == null) {
      channel = new NioDatagramChannel();
    } else {
      switch (family) {
        case IPv4:
          channel = new NioDatagramChannel(InternetProtocolFamily.IPv4);
          break;
        case IPv6:
          channel = new NioDatagramChannel(InternetProtocolFamily.IPv6);
          break;
        default:
          channel = new NioDatagramChannel();
      }
    }
    if (options.getSendBufferSize() != -1) {
      channel.config().setSendBufferSize(options.getSendBufferSize());
    }
    if (options.getReceiveBufferSize() != -1) {
      channel.config().setReceiveBufferSize(options.getReceiveBufferSize());
    }
    channel.config().setReuseAddress(options.isReuseAddress());
    if (options.getTrafficClass() != -1) {
      channel.config().setTrafficClass(options.getTrafficClass());
    }
    channel.config().setBroadcast(options.isBroadcast());
    channel.config().setLoopbackModeDisabled(options.isLoopbackModeDisabled());
    if (options.getMulticastTimeToLive() != -1) {
      channel.config().setTimeToLive(options.getMulticastTimeToLive());
    }
    if (options.getMulticastNetworkInterface() != null) {
      try {
        channel.config().setNetworkInterface(NetworkInterface.getByName(options.getMulticastNetworkInterface()));
      } catch (SocketException e) {
        throw new IllegalArgumentException("Could not find network interface with name " + options.getMulticastNetworkInterface());
      }
    }
    return channel;
View Full Code Here

Examples of io.netty.channel.socket.nio.NioDatagramChannel

                    @Override
                    public Bootstrap newInstance() {
                        return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
                            @Override
                            public Channel newChannel() {
                                return new NioDatagramChannel(InternetProtocolFamily.IPv4);
                            }

                            @Override
                            public String toString() {
                                return NioDatagramChannel.class.getSimpleName() + ".class";
View Full Code Here

Examples of io.netty.channel.socket.nio.NioDatagramChannel

                    @Override
                    public Bootstrap newInstance() {
                        return new Bootstrap().group(nioWorkerGroup).channelFactory(new ChannelFactory<Channel>() {
                            @Override
                            public Channel newChannel() {
                                return new NioDatagramChannel(InternetProtocolFamily.IPv4);
                            }

                            @Override
                            public String toString() {
                                return NioDatagramChannel.class.getSimpleName() + ".class";
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.