Search in sources :

Example 1 with RxtxDeviceAddress

use of io.netty.channel.rxtx.RxtxDeviceAddress in project netty by netty.

the class RxtxClient method main.

public static void main(String[] args) throws Exception {
    EventLoopGroup group = new OioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(group).channel(RxtxChannel.class).handler(new ChannelInitializer<RxtxChannel>() {

            @Override
            public void initChannel(RxtxChannel ch) throws Exception {
                ch.pipeline().addLast(new LineBasedFrameDecoder(32768), new StringEncoder(), new StringDecoder(), new RxtxClientHandler());
            }
        });
        ChannelFuture f = b.connect(new RxtxDeviceAddress(PORT)).sync();
        f.channel().closeFuture().sync();
    } finally {
        group.shutdownGracefully();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) OioEventLoopGroup(io.netty.channel.oio.OioEventLoopGroup) RxtxDeviceAddress(io.netty.channel.rxtx.RxtxDeviceAddress) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) StringEncoder(io.netty.handler.codec.string.StringEncoder) EventLoopGroup(io.netty.channel.EventLoopGroup) OioEventLoopGroup(io.netty.channel.oio.OioEventLoopGroup) RxtxChannel(io.netty.channel.rxtx.RxtxChannel) Bootstrap(io.netty.bootstrap.Bootstrap)

Aggregations

Bootstrap (io.netty.bootstrap.Bootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 OioEventLoopGroup (io.netty.channel.oio.OioEventLoopGroup)1 RxtxChannel (io.netty.channel.rxtx.RxtxChannel)1 RxtxDeviceAddress (io.netty.channel.rxtx.RxtxDeviceAddress)1 LineBasedFrameDecoder (io.netty.handler.codec.LineBasedFrameDecoder)1 StringDecoder (io.netty.handler.codec.string.StringDecoder)1 StringEncoder (io.netty.handler.codec.string.StringEncoder)1