Netty使用实例(二)

2014-11-24 02:50:53 · 作者: · 浏览: 10
ine() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
pipeline.addLast("handler", new HelloWorldClientHandler());
return pipeline;
}
});
//创建无连接传输channel的辅助类(UDP),包括client和server
ChannelFuture future = bootstrap.connect(new InetSocketAddress(
"localhost", 8080));
future.getChannel().getCloseFuture().awaitUninterruptibly();
bootstrap.releaseExternalResources();
}


@Test
public void testNetty(){
testServer();
testClient();
}


}