netty server:
public class NettyServer {
public static void main(String[] args) {
EventLoopGroup bossGroup=new NioEventLoopGroup(1);//处理连接请求
EventLoopGroup workerGroup=new NioEventLoopGroup();//默认线程数量为cpu核数的两倍,处理业务
try {
ServerBootstrap bootstrap=new ServerBootstrap();//创建服务器端的启动对象
bootstrap.group(bossGroup,workerGroup)
.channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG,1024)
.childHandler(new ChannelInitializer<SocketChannel>() {
protected void initChannel(SocketChannel socketChannel) {
socketChannel.pipeline().addLast(new NettyServerHandler());
}
});
System.out.println("netty server start");
//启动服务器绑定端口,bind是异步操作,sync是等待
ChannelFuture cf=bootstrap.bind(90