private void doAccept(SelectionKey key) {
        BasicAtta atta = (BasicAtta) key.attachment();
        ServerSocketChannel ch = (ServerSocketChannel) key.channel();
        SocketChannel s;
        try {
            while ((s = ch.accept()) != null) {
                s.configureBlocking(false);

                ReadAtta newAtta = new ReadAtta(atta.getSocket(), s);
                s.register(selector, OP_READ, newAtta);
            }
        } catch (ClosedChannelException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            // eg: too many open files. do not quit
            e.printStackTrace();
        }
    }