public NioChannel doAccept(NioSelectorLoop selectorLoop) {

        SocketChannel socketChannel = null;
        NioChannel channel = null;
        try {
            socketChannel = serverSocketChannel.accept();
            socketChannel.configureBlocking(false);

            if (serverConfig.getTcpNoDelay() != null) {
                socketChannel.socket().setTcpNoDelay(serverConfig.getTcpNoDelay());
            }
            if (serverConfig.getReceiveBufferSize() != null) {
                socketChannel.socket().setReceiveBufferSize(serverConfig.getReceiveBufferSize());
            }
            if (serverConfig.getKeepAlive() != null) {
                socketChannel.socket().setKeepAlive(serverConfig.getKeepAlive());
            }
            if (serverConfig.getReuseAddress() != null) {
                socketChannel.socket().setReuseAddress(serverConfig.getReuseAddress());
            }
            if (serverConfig.getIpTos() != null) {
                socketChannel.socket().setTrafficClass(serverConfig.getIpTos());
            }
            if (serverConfig.getOobInline() != null) {
                socketChannel.socket().setOOBInline(serverConfig.getOobInline());
            }
            if (serverConfig.getSoLinger() != null) {
                socketChannel.socket().setSoLinger(true, serverConfig.getSoLinger());
            }
            channel = new NioChannelImpl(selectorLoop, this, socketChannel, eventHandler(), serverConfig);
            channelInitializer.initChannel(channel);
            this.idleDetector.addChannel(channel);

            socketChannel.register(selectorLoop.selector(), SelectionKey.OP_READ, channel);

        } catch (IOException e) {
            LOGGER.info("accept the connection IOE", e);
        }

        if (channel != null) {
            eventHandler().channelConnected(channel);
        }
        return channel;
    }
@author Robert HG (254963746@qq.com) on 1/24/16.
lts-core/src/main/java/com/github/ltsopensource/nio/processor/NioServerProcessor.java