@Override
	protected Object doInBackground() throws Exception {
		socketChannel.register(selector, SelectionKey.OP_CONNECT);

		while (running) {
			selector.select();

			for (Iterator<SelectionKey> it = selector.selectedKeys().iterator(); it
					.hasNext();) {
				SelectionKey key = it.next();
				it.remove();
				try {
					if (key.isReadable()) {
						read(key);
					} else if (key.isWritable()) {
						write(key);
					} else if (key.isConnectable()) {
						connect(key);
					}

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

			}
		}

		return null;

	}