public void startServer() throws IOException {

        System.out.println("channel server started...");

        byte[] response = null;
        response = getResponse();

        try (ServerSocketChannel ssc = ServerSocketChannel.open();
             Selector selector = Selector.open()) {

            ssc.configureBlocking(false);
            ssc.bind(new InetSocketAddress(host, port), 100);
            ssc.register(selector, SelectionKey.OP_ACCEPT);

            while (true) {

                int select = selector.select();
                if (select == 0) {
                    continue;
                }

                Iterator<SelectionKey> iterator = selector.selectedKeys().iterator();

                while (iterator.hasNext()) {

                    SelectionKey key = iterator.next();
                    iterator.remove();

                    if (!key.isValid()) {
                        continue;
                    }

                    if (key.isAcceptable()) {
                        accept(key, selector);
                    } else if (key.isReadable()) {
                        read(key);
                    } else if (key.isWritable()) {
                        write(key);
                    }

                }

            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }