阅读背景:

NettySocket编程

来源:互联网 

工程构造图

 

一、Socket服务端

1、创立MyServer 类

public class MyServer {
    public static void main(String[] args) throws  Exception{
        EventLoopGroup bossGroup = new NioEventLoopGroup();
        EventLoopGroup worderGroup = new NioEventLoopGroup();
        try{
           
            ServerBootstrap serverBootstrap = new ServerBootstrap();
            serverBootstrap.group(bossGroup,worderGroup).channel(NioServerSocketChannel.class)
                    .childHandler(new MyServerinitializer());

            ChannelFuture channelFuture = serverBootstrap.bind(8899).sync();
            channelFuture.channel().closeFuture().sync();
        }finally {
            bossGroup.shutdownGracefully();
            worderGroup.shutdownGracefully();
        }
    }
}
public



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: