Example usage for io.netty.channel.udt.nio NioUdtProvider BYTE_RENDEZVOUS

List of usage examples for io.netty.channel.udt.nio NioUdtProvider BYTE_RENDEZVOUS

Introduction

In this page you can find the example usage for io.netty.channel.udt.nio NioUdtProvider BYTE_RENDEZVOUS.

Prototype

ChannelFactory BYTE_RENDEZVOUS

To view the source code for io.netty.channel.udt.nio NioUdtProvider BYTE_RENDEZVOUS.

Click Source Link

Document

ChannelFactory for UDT Byte Rendezvous.

Usage

From source file:com.flysoloing.learning.network.netty.udt.echo.rendezvousBytes.ByteEchoPeerBase.java

License:Apache License

public void run() throws Exception {
    final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory,
            NioUdtProvider.BYTE_PROVIDER);
    try {/*  w  ww  . j a  v  a 2s.c  o  m*/
        final Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(connectGroup).channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    protected void initChannel(UdtChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO),
                                new ByteEchoPeerHandler(messageSize));
                    }
                });
        final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
        future.channel().closeFuture().sync();
    } finally {
        connectGroup.shutdownGracefully();
    }
}

From source file:io.aos.netty5.udt.echo.rendezvousBytes.ByteEchoPeerBase.java

License:Apache License

public void run() throws Exception {
    final ExecutorServiceFactory connectFactory = new DefaultExecutorServiceFactory("rendezvous");
    final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory,
            NioUdtProvider.BYTE_PROVIDER);

    try {/*from   w  w  w .ja v  a 2 s  .com*/
        final Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(connectGroup).channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
                .handler(new ChannelInitializer<UdtChannel>() {
                    @Override
                    protected void initChannel(UdtChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO),
                                new ByteEchoPeerHandler(messageSize));
                    }
                });
        final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
        future.channel().closeFuture().sync();
    } finally {
        connectGroup.shutdownGracefully();
    }
}