INNER CODE UNIT · Java
initChannel
luxiaoxun/Code4Java · MapHttpService/src/main/java/com/luxx/map/MapHttpServer.java:45
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new HttpResponseEncoder());
ch.pipeline().addLast(new HttpRequestDecoder());
//aggregates an HttpMessage and its following HttpContents into a single FullHttpRequest or FullHttpResponse
//with no following HttpContents.
ch.pipeline().addLast(new HttpObjectAggregator(65536));
ch.pipeline().addLast(eventExecutorGroup, new HttpServerInboundHandler());
}
}).option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, false)
.childOption(ChannelOption.TCP_NODELAY, true);
ChannelFuture f = b.bind(port).sync();
f.channel().closeFuture().sync();
} finally {
destroy();
}