KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 Code Server: 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)); } } Server Handler: 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(); } } Client: 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)); } } Client Handler: public class ClientHandler extends SimpleChannelHandler{ public void messageRecieved(Chann
Tags (comma-separated)
Save Edits
Cancel