<div>Hi Christian,</div>
<div> </div>
<div>Thanks! I got it. They echo each other just like &quot;wild ping-pong&quot;. 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">&lt;<a href="mailto:chrismfwrd@gmail.com">chrismfwrd@gmail.com</a>&gt;</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&#39;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&lt;<a href="mailto:jmi258@gmail.com">jmi258@gmail.com</a>&gt; wrote:<br>&gt; Hi Trustin or any other experienced Netty user,<br>&gt;<br>&gt; I&#39;ve downloaded Netty 3.1.2. GA and am currently trying to learn it via your<br>
&gt; example of Echo. But I&#39;m having a hard time understanding the example. I<br>&gt; started the server first and seeing a bunch of &quot;0.000 MiB/s&quot; output to the<br>&gt; console.<br>&gt;<br>&gt; I then started the client with the same port (as hard-coded in the server)<br>
&gt; of 8080. I then see the output to the console as a bunch &quot;0.0nn MiB/s&quot; where<br>&gt; nn can be any number.<br>&gt;<br>&gt; I understand that the outout is from the thread ThroughputMonitor.<br>&gt;<br>&gt; I&#39;m not sure if I understand the scenario how things work between the client<br>
&gt; and the server.<br>&gt; The brief description from EchoClient.java is &quot;Sends one message when a<br>&gt; connection is open and echoes back any received data to the server.&quot;<br>&gt; The brief description from EchoServer.java is &quot;Echoes back any received data<br>
&gt; from a client.&quot;<br>&gt; The EchoHandler.java has the method below:<br>&gt;<br>&gt; public void channelConnected (ChannelHandlerContext ctx, ChannelStateEvent<br>&gt; e) {<br>&gt;<br>&gt; // Send the first message. Server will not send anything here<br>
&gt;<br>&gt; // because the firstMessage&#39;s capacity is 0.<br>&gt;<br>&gt; e.getChannel().write(<br>&gt;<br>&gt; firstMessage);<br>&gt;<br>&gt; }<br>&gt;<br>&gt; So between the client and the server, who sends a message and who echoes the<br>
&gt; message?<br>&gt; When I added System.out<br>&gt; .println(&quot;Message from channelConnected: &quot; + firstMessage.toString()); in<br>&gt; the method, I can see<br>&gt;<br>&gt; Message from channelConnected: BigEndianHeapChannelBuffer(ridx=0, widx=0,<br>
&gt; cap=0)<br>&gt;<br>&gt; once when starting EchoClient.<br>&gt;<br>&gt; Could you please explain it to me? This example is a fundamental one. It<br>&gt; should be good starting point for me to understand Netty&#39;s NIO framework.<br>
&gt;<br>&gt; If there is a forum some where about this topic and where I should post any<br>&gt; question like this, please advice as well.<br>&gt;<br>&gt; Thanks in advance<br>&gt; Jason<br></div></div>&gt; _______________________________________________<br>
&gt; netty-dev mailing list<br>&gt; <a href="mailto:netty-dev@lists.jboss.org">netty-dev@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-dev</a><br>
&gt;<br>&gt;<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>