<div>Hi Christian,</div>
<div> </div>
<div>Thanks! I got it. They echo each other just like "wild ping-pong". I like that.</div>
<div> </div>
<div>Cheers,</div>
<div>Jason<br><br></div>
<div class="gmail_quote">On Mon, Aug 31, 2009 at 8:24 AM, Christian Migowski <span dir="ltr"><<a href="mailto:chrismfwrd@gmail.com">chrismfwrd@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi Jason,<br><br>i'll try to comment the example, hope it helps:<br><br>1. in EchoClient.java line 63 an instance of EchoHandler.java<br>
firstMessage is initialized with numbers because the 2nd constructor<br>is used<br>2. in EchoServer.java an instance of EchoHandler.java firstMessage is<br>initialized as empty (i.e. no data) because the 1st constructor is<br>
used<br>3. in EchoClient.java line 67 the client connects to the server, when<br>this is done, channelConnected() method of EchoHandler is invoked in<br>both the client and the server, but with different processing:<br>3a) EchoHandler.channelConnected of EchoClient will send firstMessage<br>
that is initialized with numbers<br>3b) EchoHandler.channelConnected of EchoServer will not send anything<br>because firstMessage is empty (there is nothing to send, even IF write<br>is called)<br>4. Echohandler.messageReceived of EchoServer is invoked because it<br>
received the message from the client, in this method the data received<br>is echoed back to the client<br>5. now Echohandler.messageReceived of EchoClient is doing the same as<br>the one of EchoServer in 4.) and the wild ping-pong begins until you<br>
terminate the program<br><br>hope this helps,<br>greetings,<br>christian!<br>
<div>
<div></div>
<div class="h5"><br><br>On Sat, Aug 29, 2009 at 12:54 AM, J. Mi<<a href="mailto:jmi258@gmail.com">jmi258@gmail.com</a>> wrote:<br>> Hi Trustin or any other experienced Netty user,<br>><br>> I've downloaded Netty 3.1.2. GA and am currently trying to learn it via your<br>
> example of Echo. But I'm having a hard time understanding the example. I<br>> started the server first and seeing a bunch of "0.000 MiB/s" output to the<br>> console.<br>><br>> I then started the client with the same port (as hard-coded in the server)<br>
> of 8080. I then see the output to the console as a bunch "0.0nn MiB/s" where<br>> nn can be any number.<br>><br>> I understand that the outout is from the thread ThroughputMonitor.<br>><br>> I'm not sure if I understand the scenario how things work between the client<br>
> and the server.<br>> The brief description from EchoClient.java is "Sends one message when a<br>> connection is open and echoes back any received data to the server."<br>> The brief description from EchoServer.java is "Echoes back any received data<br>
> from a client."<br>> The EchoHandler.java has the method below:<br>><br>> public void channelConnected (ChannelHandlerContext ctx, ChannelStateEvent<br>> e) {<br>><br>> // Send the first message. Server will not send anything here<br>
><br>> // because the firstMessage's capacity is 0.<br>><br>> e.getChannel().write(<br>><br>> firstMessage);<br>><br>> }<br>><br>> So between the client and the server, who sends a message and who echoes the<br>
> message?<br>> When I added System.out<br>> .println("Message from channelConnected: " + firstMessage.toString()); in<br>> the method, I can see<br>><br>> Message from channelConnected: BigEndianHeapChannelBuffer(ridx=0, widx=0,<br>
> cap=0)<br>><br>> once when starting EchoClient.<br>><br>> Could you please explain it to me? This example is a fundamental one. It<br>> should be good starting point for me to understand Netty's NIO framework.<br>
><br>> If there is a forum some where about this topic and where I should post any<br>> question like this, please advice as well.<br>><br>> Thanks in advance<br>> Jason<br></div></div>> _______________________________________________<br>
> netty-dev mailing list<br>> <a href="mailto:netty-dev@lists.jboss.org">netty-dev@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/netty-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-dev</a><br>
><br>><br><br>_______________________________________________<br>netty-dev mailing list<br><a href="mailto:netty-dev@lists.jboss.org">netty-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/netty-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-dev</a><br>
</blockquote></div><br>