Ridiculous newbie question
Johnny Luong
johnny.luong at trustcommerce.com
Mon Apr 5 13:16:47 EDT 2010
Try removing the "Hello " + ...
-Johnny
vibeofboston wrote:
> This might sound really stupid but I can't seem to figure it out. I have the
> same exact code as in Chapter 1 of Netty documentation but I can't seem to
> connet to the server thru telnet.
> I looked at the ports running [using netstat] and it said established but
> then it went to TIME_WAIT. why is the connection lost.
> ChannelFactory factory= new
> NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool());
>
> ServerBootstrap bootstrapper= new ServerBootstrap(factory);
>
> EchoHandler handler= new EchoHandler();
> ChannelPipeline pipeline= bootstrapper.getPipeline();
>
> pipeline.addLast("handler", handler);
>
> bootstrapper.setOption("child.tcpNoDelay", true);
> bootstrapper.setOption("child.keepAlive", true);
> bootstrapper.setOption("child.reuseAddress", true);
>
> bootstrapper.bind(new InetSocketAddress("localhost", 8080));
> System.out.println("Running...");
>
>
>
>
> @ChannelPipelineCoverage("all")
> public class EchoHandler extends SimpleChannelHandler{
>
> @Override
> public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
> throws Exception {
> Channel channel= e.getChannel();
> channel.write("Hello " + e.getMessage());
> }
>
> @Override
> public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
> throws Exception {
> Channel ch= e.getChannel();
> ch.close();
> }
> }
>
More information about the netty-users
mailing list