public void run() {

		while (started) {
			try {
				selector.select();
				Iterator<SelectionKey> selectedKeys = selector.selectedKeys().iterator();

				while (selectedKeys.hasNext()) {
					try {
						SelectionKey key = (SelectionKey) selectedKeys.next();
						selectedKeys.remove();

						if (!key.isValid()) {
							continue;
						}

						if (key.isReadable()) {

							readUDP(key);
							
							key.interestOps(SelectionKey.OP_WRITE);

						} else if (key.isWritable()) {

							writeUDP(key);
							
							key.interestOps(SelectionKey.OP_READ);

						}
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}