xnio / netty-xnio-transport

Netty XNIO Transport

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

netty-xnio-transport

This is a Netty Transport powered by XNIO. It can be used to either wrap an existing StreamConnection and AcceptingChannel or to bootstrap a Netty powered server directly.

To bootstrap a server use it the same way as other transport implementations. The following code snipped shows an example:

    public void run() throws Exception {
        // Configure the server.
        EventLoopGroup group = new XnioEventLoopGroup(4);
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(group)
             .childHandler(new HelloServerInitializer())

             .channel(XnioServerSocketChannel.class)
             .option(XnioChannelOption.BALANCING_TOKENS, 1)
             .option(XnioChannelOption.BALANCING_CONNECTIONS, 2)
             .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
            Channel ch = b.bind(port).sync().channel();
            ch.closeFuture().sync();
        } finally {
            group.shutdownGracefully().sync();
        }
    }

The branch 0.1.x is there to support Java 8.

About

Netty XNIO Transport

License:Apache License 2.0


Languages

Language:Java 100.0%