DefaultSocketSessionConfig 类
extends AbstractSocketSessionConfig extends AbstractIoSessionConfig
implements SocketSessionConfig,IoSessionConfig
protected IoService parent; private boolean defaultReuseAddress; private boolean reuseAddress; //接受数据缓冲区大小 private int receiveBufferSize = -1; //发送数据缓冲区大小 private int sendBufferSize = -1; private int trafficClass = 0; private boolean keepAlive = false; private boolean oobInline = false; private int soLinger = -1; private boolean tcpNoDelay = false;
public void init(IoService parent) { this.parent = parent; if (parent instanceof SocketAcceptor) { defaultReuseAddress = true; } else { defaultReuseAddress = false; } reuseAddress = defaultReuseAddress; }
doSetAll方法
protected final void doSetAll(IoSessionConfig config) { if (!(config instanceof SocketSessionConfig)) { return; } if (config instanceof AbstractSocketSessionConfig) { // Minimize unnecessary system calls by checking all 'propertyChanged' properties. AbstractSocketSessionConfig cfg = (AbstractSocketSessionConfig) config; if (cfg.isKeepAliveChanged()) { setKeepAlive(cfg.isKeepAlive()); } if (cfg.isOobInlineChanged()) { setOobInline(cfg.isOobInline()); } if (cfg.isReceiveBufferSizeChanged()) { setReceiveBufferSize(cfg.getReceiveBufferSize()); } if (cfg.isReuseAddressChanged()) { setReuseAddress(cfg.isReuseAddress()); } if (cfg.isSendBufferSizeChanged()) { setSendBufferSize(cfg.getSendBufferSize()); } if (cfg.isSoLingerChanged()) { setSoLinger(cfg.getSoLinger()); } if (cfg.isTcpNoDelayChanged()) { setTcpNoDelay(cfg.isTcpNoDelay()); } if (cfg.isTrafficClassChanged() && getTrafficClass() != cfg.getTrafficClass()) { setTrafficClass(cfg.getTrafficClass()); } } else { SocketSessionConfig cfg = (SocketSessionConfig) config; setKeepAlive(cfg.isKeepAlive()); setOobInline(cfg.isOobInline()); setReceiveBufferSize(cfg.getReceiveBufferSize()); setReuseAddress(cfg.isReuseAddress()); setSendBufferSize(cfg.getSendBufferSize()); setSoLinger(cfg.getSoLinger()); setTcpNoDelay(cfg.isTcpNoDelay()); if (getTrafficClass() != cfg.getTrafficClass()) { setTrafficClass(cfg.getTrafficClass()); } }
}