netty
2019-02-15 16:01:30 5 举报
netty源码实现流程图
作者其他创作
大纲/内容
省略和server端一样的步骤
NioServerSocketChannel
run启动轮询
execute(task)
1
initAndRegister
pipeline.addLast(handler)
3handler责任链传递
child.pipeline().addLast(childHandler)
remove把自己移除
doBind
2
register0
ChannelInitializer
2调用特殊的handlerChannelInitializer
run
DefaultChannelPipeline
提交任务
childGroup.register(child)
ServerBootstrap
从head到tail
pipeline.addLast(new ServerBootstrapAcceptor())
NioMessageUnsafe
3
initChannel
bind
AbstractChannel
channelRead
new HeadContextnew TailContext
把channel注册到selector上doRegister
newUnsafe
1handlerAdded
channelRegistered
从tail到head调用outbound
NioMessageUnsafe()
read
AbstractChannelHandlerContext
beginRead
AbstractBootstrap
NioEventLoop
fireChannelRegistered
invokeHandlerAddedIfNeeded
run轮询acceptor事件
callHandlerAdded0
AbstractNioChannel
init(channel)
doReadMessages
1p.addLast(new ChannelInitializer<Channel>())
1获取客户端socketchannel
ServerBootstrapAcceptor继承ServerBootstrap
doBind0
newChannelPipeline
fireChannelRead
0 条评论
下一页