title: How to get server response with netty client
body: <p>I want to write a netty based client. It should have method <em>public String send(String msg);</em> which should return response from the server or some future - doesen't matter. Also it should be multithreaded. Like this:</p>
  
  <pre><code>public class Client {
  public static void main(String[] args) throws InterruptedException {
      Client client = new Client();
  
  }
  
  private Channel channel;
  
  public Client() throws InterruptedException {
      EventLoopGroup loopGroup = new NioEventLoopGroup();
  
      Bootstrap b = new Bootstrap();
      b.group(loopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer&lt;SocketChannel&gt;() {
          @Override
          protected void initChannel(SocketChannel ch) throws Exception {
              ch.pipeline().addLast(new StringDecoder()).
                      addLast(new StringEncoder()).
                      addLast(new ClientHandler());
          }
      });
      channel = b.connect("localhost", 9091).sync().channel();
  }
  
  public String sendMessage(String msg) {
      channel.writeAndFlush(msg);
      return ??????????;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And I don't get how can I retrieve response from server after I invoke writeAndFlush(); What should I do?</p>
  
  <p>Also I use Netty 4.0.18.Final</p>