title: in netty, we can only write and receive data less than 1024bytes: how we can write or receive more?
body: <p>When writing 2048bytes in on handler, the messageRevieved method should be called twice to receive the all data... how I can receive the 2048bytes data in </p>
  
  <p><strong>Code</strong></p>
  
  <p><strong>Server:</strong></p>
  
  <pre><code>public class Server{
      public static void main(String[] args){
          ChannelFactory factory=new NioServerSocketChannelFactory(
              Executors.newCachedThreadPool(),
              Executors.newCachedThreadPool());
          ServerBootstrap bootstrap=new ServerBootstrap(factory);
          bootstrap.setPipelineFactory(new CarPipelineFactory());
  
          bootstrap.setOption("child.tcpNoDelay", true);
          bootstrap.setOption("child.keepAlive", true);
  
          bootstrap.bind(new InetSocketAddress(8989));
      }
  }
  </code></pre>
  
  <p><strong>Server Handler:</strong></p>
  
  <pre><code>public class ServerHandler extends SimpleChannelHandler{
  
      public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e){
          byte[] resp=data.getBytes();//data is a String greater than 1024bytes;
          ChannelBuffer buffer=ChannelBuffers.buffer(resp.length);
          buffer.writerBytes(resp);
          e.getChannel().write(buffer);
          buffer.clear();
      }
  }
  </code></pre>
  
  <p><strong>Client:</strong></p>
  
  <pre><code>public class Client{
      public static void main(String[] args){
          ChannelFactory channelFactory=new NioClientSocketChannelFactory(
              Executors.newCachedThreadPool(),
              Executors.newCachedThreadPool());
          ClientBootstrap bootstrap=new ClientBootstrap(channelFactory);
          bootstrap.getPipeline().addLast("handler", new PhoneClientHandler());
  
          bootstrap.setOption("child.tcpNoDelay", true);
          bootstrap.setOption("child.keepAlive", true);
  
          bootstrap.connect(new InetSocketAddress("127.0.0.1",8181));
      }
  }
  </code></pre>
  
  <p><strong>Client Handler:</strong></p>
  
  <pre><code>public class ClientHandler extends SimpleChannelHandler{
      public void messageRecieved(ChannelHandlerContext ctx, ChannelStateEvent e){
          ChannelBuffer buffer=(ChannelBuffer)e.getMessage();
          int size=buffer.readableBytes();
          byte[] bytes=new byte[size];
          buffer.readBytes(bytes);
          buffer.clear();
          System.out.println(new String(bytes));//if the data size&gt;1024,the String will speprate into parts.
      }
  }
  </code></pre>