for(Iterator k = nioDaemon.getSelector().keys().iterator(); k.hasNext(); ) {
SelectionKey key = (SelectionKey)k.next();
// close an invalid connection
if(!key.isValid()) {
NIOAttachment attachment = (NIOAttachment)key.attachment();
attachment.close(new IOException("Connection closed"));
// close the server socket
} else if((key.interestOps() & SelectionKey.OP_ACCEPT) != 0) {
try {