public void run() {

	/* open Selector and ServerSocketChannel */
		try {
			Selector selector = Selector.open();
			ServerSocketChannel serverSocketChannel = ServerSocketChannel
					.open();
			/* check if they were successfully opened */
			if ((serverSocketChannel.isOpen()) && (selector.isOpen())) {
				/* non-blocking mode */
				serverSocketChannel.configureBlocking(false);
				/* bind the server socket channel to port */
				serverSocketChannel.bind(new InetSocketAddress(port));
				/* register the current channel with the given selector */
				serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
                System.out.println("Wait for connections ..");
				while (true) {
					/* waiting for incomming events */
					selector.select();

					/* select a key for a processing an event */
					Iterator keys = selector.selectedKeys().iterator();

					while (keys.hasNext()) {
						SelectionKey key = (SelectionKey) keys.next();

						/* remove key such that the same key won't come up again */
						keys.remove();

						if (!key.isValid()) {
							continue;
						}
						/* new connection/reading event/writing event */
						if (key.isAcceptable()) {
							acceptOP(key, selector);
						} else if (key.isReadable()) {
							this.readOP(key);
						} else if (key.isWritable()) {
							this.writeOP(key);
						}
					}
				}

			} else {
			
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}