Code example for SelectionKey

Methods: channel

0
		return null; 
	} 
 
	private void writeToServerChannel(SelectionKey key, Object message)
			throws IOException { 
		ServerSocketChannel channel = (ServerSocketChannel) key.channel();
		SocketChannel client = channel.accept();
		client.configureBlocking(false);
		client.register(selector, SelectionKey.OP_READ);
		System.out.println("get" + client);
		ByteBuffer dst = ByteBuffer.allocate(1024);
		dst.put(message.toString().getBytes());
		dst.flip();
		client.write(dst);
	} 
 
	/***/ 
	private void writeToCommonChannel(SelectionKey key, Object message)
			throws IOException { 
		SocketChannel client = (SocketChannel) key.channel();
		client.configureBlocking(false);
		client.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
		ByteBuffer dst = ByteBuffer.allocate(1024);
		dst.put(message.toString().getBytes());
		dst.flip();
Connect your IDE to all the code out there  Get Codota for Java