private void handleKey(SelectionKey key) throws IOException{
		// dealing with canceled keys
		if( ! key.isValid() ){
			return;
		}

		KeyAttachment attach = ((KeyAttachment) key.attachment());
		IoHandler handler = attach.handler;

		if( key.isAcceptable() ){
			handler.accept(key);
			// keys that are acceptable will not be any of the other things
			return;
		}

		if( key.isConnectable() ){
			handler.connect(key);
		}

		if( key.isWritable() ){
			handler.write(key);
		}

		if( key.isReadable() ){
			handler.read(key);
		}
	}