<div>
                    Hi,
                </div><div><br></div><div>Thanks for the feed back. &nbsp;Since it will make the example a little bit longer than I expected, I'd like to pre-calculate how many milliseconds 70 years from 1900 are and simply add it to System.currentTimeMillis(). &nbsp;What do you think?</div><div><br></div><div>Let me also add the instruction on how to test the server using the rdate command as you show.</div><div><br></div><div>Thanks a lot!</div><div>--&nbsp;<br><a href="http://gleamynode.net/">Trustin Lee</a><br></div>
                 
                <p style="color: #A0A0A8;">On Wednesday, September 7, 2011 at 10:59 PM, Maverick.Crank.GRey wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div>Hello Trustin,<br><br>In additional to the issue found by Tiberiu I would like to mentioned that <br><a href="http://docs.jboss.org/netty/3.2/guide/html_single/index.html#d0e440">http://docs.jboss.org/netty/3.2/guide/html_single/index.html#d0e440</a> the<br>suggested implementation  of  <a href="http://tools.ietf.org/html/rfc868">http://tools.ietf.org/html/rfc868</a> TIME<br>protocol (RFC 868)  is incorrect. According to RFC 868 "The Time service<br>sends back to the originating source the time in seconds since midnight on<br>*January first 1900*." and not "the difference, measured in milliseconds,<br>between the current time and midnight, *January 1, 1970 UTC*" returned by <br><a href="http://download.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis(">http://download.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis(</a>)<br>java.lang.System.currentTimeMillis() .<br><br>Here is a little bit corrected example of TimeServerHandler<br><br>package ru.spb.mcgrey.test.java.netty.server;<br><br>import org.jboss.netty.buffer.ChannelBuffer;<br>import org.jboss.netty.buffer.ChannelBuffers;<br>import org.jboss.netty.channel.*;<br><br>import java.util.Calendar;<br><br><br>public class TimeServerHandler extends SimpleChannelHandler {<br><br>    @Override<br>    public void channelConnected(ChannelHandlerContext ctx,<br>ChannelStateEvent e) {<br>        Channel ch = e.getChannel();<br>        <br>        ChannelBuffer time = ChannelBuffers.buffer(4);<br>        <br>        Calendar rightNow = Calendar.getInstance();<br>        rightNow.roll(Calendar.YEAR, 70);  // to be comply with RFC 868<br>        <br>        long timeMs = rightNow.getTimeInMillis();<br>        long timeS = timeMs / 1000;<br>        time.writeInt((int)timeS);<br>        <br>        ChannelFuture f = ch.write(time);<br>        <br>        f.addListener(ChannelFutureListener.CLOSE);<br>    }<br><br>    @Override<br>    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)<br>{<br>        e.getCause().printStackTrace();<br>        e.getChannel().close();<br>    }<br>}<br><br>BTW, being comply with RFC 868 gives us the additional advantage. We can use<br>standard tools to test our time server instead of writing a Time Client. I<br>used  <a href="http://linux.die.net/man/1/rdate">http://linux.die.net/man/1/rdate</a> rdate  for my tests.<br><br>$ rdate -o 8037 -p localhost<br>Thu Sep  8 17:45:27 UTC 2011<br><br>I date to hope, my post can make Netty documentation a little bit correctly<br>=) <br><br><br>--<br>View this message in context: <a href="http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Time-Server-Example-Error-in-documentation-tp6710743p6767899.html">http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Time-Server-Example-Error-in-documentation-tp6710743p6767899.html</a><br>Sent from the Netty User Group mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>netty-users mailing list<br><a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/netty-users">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>