final Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
final SelectionKey key = it.next();
final SelectorListener listener = (SelectorListener) key.attachment();
int ops = key.readyOps();
boolean isAcceptable = (ops & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT;
boolean isConnectable = (ops & SelectionKey.OP_CONNECT) == SelectionKey.OP_CONNECT;
boolean isReadable = (ops & SelectionKey.OP_READ) == SelectionKey.OP_READ;
boolean isWritable = (ops & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE;
listener.ready(isAcceptable, isConnectable, isReadable, isReadable ? readBuffer : null,