经常看到Tornado的监听端口,身为Javaista,tomcat对底层封装极其丧心病狂,计划开始手撸一个基于Netty的http服务器,并不断完善,顺便学习NIO和RPC
第一个超级简单,hello world,本次编码使用kotlin实现,具体和Java没有太大区别,接下来从netty各个组件开始学习完善优化
- channel、eventloop和channelfuture
- netty数据容器
- 编解码
- 多线程
- 网络协议
package com.kotlin.server
import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.close
import io.netty.handler.codec.http.HttpRequest
import io.netty.bootstrap.ServerBootstrap
import io.netty.buffer.Unpooled
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter
import io.netty.channel.ChannelInitializer
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioServerSocketChannel
import java.io.UnsupportedEncodingException
import io.netty.channel.socket.SocketChannel
import io.netty.handler.codec.http.*
object Htt