The first 8 bytes give you the information you need to know if the string has already arrived or no, so for example if you receive
01999935http://mina.ap you know that you are missing bytes since the length of "http://mina.ap" is less than 35 So you should implement a protocol that expects at least 8 bytes, and then, knowing the length of the URL, wait for that amount of bytes. After that, just start over :) You may receive something like 01200915mina.apache.org01200935http://mi but in your code, after you process the first url, you have already everything you need for the second URL (in this case, wait for more data) On Fri, Apr 24, 2009 at 12:49 PM, Pietro Guerrieri <[email protected]> wrote: > Hi, > I'm italian and sorry for my bad english > > I have a problem with MINA 2.0, I need help > > I must recive e stream of tcp of variable string. > > Examples of string: > 01999935http://mina.apache.org/contact.html > or better is: > first 2 position is myAction (in this examples is "01") > then come the year (in this example is "9999") > then the len of the URL (in this example is "35") > ..and the URL (http://mina.apache.org/contact.html) > > so I have a message (in tcp protocol) like the examples > [myAction]01[year]9999[len]35[URL]http://mina.apache.org/contact.html > > my problem is that i recive a lot of this messages with variable length, for > example > 01200935 > http://mina.apache.org/contact.html03200922http://mina.apache.org01200915mina.apache.org..... > and so long > > that splitted are: > 01200922http://mina.apache.org > 03200935http://mina.apache.org/contact.html > 01200915mina.apache.org > > this stream of messages are very long and continuous for long time (also one > week) so I recive a long stream of tcp packets like: > ....01200935 > http://mina.apache.org/contact.html03200922http://mina.apache.org01200915mina.apache.org01200935http://mina.apache.org/contact.html03200922http://mina.apache.org01200915mina.apache.org01200935http://mina.apache.org/contact.html03200922http://mina.apache.org01200915mina.apache.org... > .. > > how I can read/recive a continuous and infinite variable string over tcp > packets with MINA!?! > > thank you > Pietro >
