ServerBootstrap介绍
ServerBootstrap也继承AbstractBootstrap,所以ServerBootstrap和Bootstrap的结构是差不多的,但是ServerBootstrap负责初始化netty服务器,并且开始监听端口的socket请求。
EchoServer
先看看Netty自带的EchoServer例子:
public final class EchoServer {
static final int PORT = Integer.parseInt(System.getProperty("port", "8007"));
public static void main(String[] args) throws Exception {
// Configure the server.
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b =