netty

k.attachment();为什么就有值了 我们自己写的nioserversocketchannle 就是null 为啥 ???

bind()---> ChannelFuture regFuture = config().group().register(channel)------>io.netty.channel.nio.NioEventLoop#run----->runAllTasks(long timeoutNanos)

----->safeExecute(task)---->io.netty.channel.AbstractChannel.AbstractUnsafe#register0--->io.netty.channel.nio.AbstractNioChannel#doRegister

①:java.nio.channels.spi.AbstractSelectableChannel#register
selectionKey = javaChannel().register(eventLoop().unwrappedSelector(), 0, this);

②:io.netty.channel.nio.NioEventLoop#select

③:io.netty.channel.socket.nio.NioServerSocketChannel#doReadMessages

head->ServerBootstrapAcceptor->tail

posted @ 2024-01-12 14:47  Me无情  阅读(3)  评论(0编辑  收藏  举报