private void startEchoServer() {
        //设置默认的监视端口
        int defaultPort = 5555;
        //新建selector和channel
        try (Selector selector = Selector.open();
             ServerSocketChannel serverSocketChannel = ServerSocketChannel.open()) {
            //检查是否正常打开
            if ((selector.isOpen()) && (serverSocketChannel.isOpen())) {

                //channel的配置
                serverSocketChannel.configureBlocking(false);
                serverSocketChannel.setOption(StandardSocketOptions.SO_RCVBUF, 256 * 1024);
                serverSocketChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);

                //绑定端口
                serverSocketChannel.bind(new InetSocketAddress(defaultPort));

                //注册当前的selector
                serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);

                System.out.println("start waiting for connection...");

                while (true) {
                    //监听调用的事件
                    selector.select();

                    //查找出调用的client的key
                    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
                    while (keys.hasNext()) {
                        SelectionKey next = keys.next();

                        keys.remove();

                        if (!next.isValid()) {
                            continue;
                        }
                        if (next.isAcceptable()) {
                            acceptOp(next, selector);
                        } else if (next.isReadable()) {
                            this.readOp(next);
                        } else if (next.isWritable()) {
                            this.writeOp(next);
                        }
                    }
                }
            } else {
                System.out.println("server socket channel or selector is not open....");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }