This topic has not yet been written. The content below is from the topic description.
1.4. Writing an Echo Server So far, we have been consuming data without responding at all. A server, however, is usually supposed to respond to a request. Let us learn how to write a response message to a client by implementing the ECHO protocol, where any received data is sent back. The only difference from the discard server we have implemented in the previous sections is that it sends the received data back instead of printing the received data out to the console. Therefore, it is enough again to modify the messageReceived method: @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { Channel ch = e.getChannel(); ch.write(e.getMessage()); } A ChannelEvent object has a reference to its associated Channel. Here, the returned Channel represents the connection which received the MessageEvent. We can get the Channel and call the write method to write something back to the remote peer. If you run the telnet command again, you will see the server sends back whatever you have sent to it.