<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoPlainText>Hello,<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>I’m still learning netty and I need to find the best
classes to do what I need or find out if I need to code it myself – we have our
own protocol that’s very, very simple – a header used to synchronize where
we’re at in the stream and then some int’s, long’s, etc. in a known order. The
entire length of the packet is known ahead of time (it's a fixed-length
packet). We intend to maintain this connection for days, weeks, months, and
years. So an example of a stream is (just the bytes -- "Packet #",
"Header", and "Payload" don't actually appear in the data):<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>Packet 1<o:p></o:p></p>
<p class=MsoPlainText>Header: 0xdeadbeef<o:p></o:p></p>
<p class=MsoPlainText>Payload: 0x00000000, 0x00000001, 0x00000002<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>Packet 2<o:p></o:p></p>
<p class=MsoPlainText>Header: 0xdeadbeef<o:p></o:p></p>
<p class=MsoPlainText>Payload: 0x00000000, 0x00000001, 0x00000002<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>We use the header (delimiter) in case (for whatever
reason – a particle from space flips a bit on the server producing these
messages) we lose where we’re at and need to synchronize with the next packet.
So say we got the following sequence:<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>Packet 1: 0xdeadbeef 0x0x00000000 0x00000000 0x00000000 <o:p></o:p></p>
<p class=MsoPlainText>Packet 2: 0xabcdabcd 0x0x00000000 0x00000000 0x00000000 <o:p></o:p></p>
<p class=MsoPlainText>Packet 3: 0xdeadbeef 0x0x00000000 0x00000000 0x00000000<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>We would want to skip packet 2 and continue on with
packet 3. We would like to know if we found a problem with packet 2, but it's
not a requirement. We also need to know if there's a significant delay between
messages (e.g. a read timeout of, say, 30 seconds or more). We only need to
ever read and never write to this stream.<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>How should I approach this? What classes should I look
at? Does DelimiterBasedFrameDecoder allow me to recover from a bad packet? Can
I recover without having to catch an exception? I'm not sure where to begin. I
know how I would do it using old IO, but I'd prefer to take advantage of
netty's power and expressiveness and I'm sure netty can handle this. I just
don't want to reinvent the wheel.<o:p></o:p></p>
<p class=MsoPlainText><o:p> </o:p></p>
<p class=MsoPlainText>Thanks!<o:p></o:p></p>
</div>
</body>
</html>