private static void processKey(Object id, SelectionKey key, SelectorManager2 mgr) throws IOException, InterruptedException {
		if(log.isLoggable(Level.FINEST))
			log.finest(id+""+key.attachment()+"proccessing");

		//This is code to try to avoid the CancelledKeyExceptions
		if(!key.channel().isOpen() || !key.isValid())
			return;
		
		//if isAcceptable, than is a ServerSocketChannel
		if(key.isAcceptable()) {
			Helper.acceptSocket(id, key);
		} 
		
		if(key.isConnectable())
			Helper.connect(id, key);
		
		if(key.isWritable()) {
			Helper.write(id, key);
		}
            
		//The read MUST be after the write as a call to key.isWriteable is invalid if the
		//read resulted in the far end closing the socket.
		if(key.isReadable()) {
			Helper.read(id, key, mgr);
		}                   
	}