类 AbstractNioMessageChannel
protected AbstractNioMessageChannel(Channel parent, SelectableChannel ch, int readInterestOp) { super(parent, ch, readInterestOp); }类 AbstractNioChannel
protected AbstractNioChannel(Channel parent, SelectableChannel ch, int readInterestOp) { super(parent); this.ch = ch; //成员变量赋值SelectionKey.OP_ACCEPT,还没有真正的绑定事件 this.readInterestOp = readInterestOp; try { //设置非阻塞 ch.configureBlocking(false); } catch (IOException e) { try { ch.close(); } catch (IOException e2) { if (logger.isWarnEnabled()) { logger.warn( "Failed to close a partially initialized socket.", e2); } } throw new ChannelException("Failed to enter non-blocking mode.", e); } }类 AbstractChannel
protected AbstractChannel(Channel parent) { this.parent = parent; id = newId(); unsafe = newUnsafe(); //创建了当前channel的pipeline和头尾handler 见(6) pipeline = newChannelPipeline(); }Netty 源码阅读笔记(6) DefaultChannelPipeline
