Re: MIDP Socket problem (for experts)




"jf@xxxxxxxxxx" <cyberpunkpor@xxxxxxxxx> wrote in message
news:1128093587.977452.82190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi.
>
> I am doing an application (MIDP) that parses XML from a TCP connection.
> I then submit the XML to the SAX Parser and then i parse it normally
> using the events. All this ok if the socket receives the exactly
> chuncks of that with well formed XML. But sometimes (if the broadband
> is small) my socket reader cath's for example n bytes:
>
> <p><xpto>sadasd<xpt
>
> then it processes submit to the parser (it won't work because is not
> well formed) and then i receive from the socket:
>
> o>adasdsad</p>
>
> i want to know if i can force the inputstream to be larger. Of course i
> can read it byte byte, but then i must code a pre-parser that will
> build the xml to the sax parser (or i code my own parser...pff)

I'm not sure if I understand the last paragraph, but couldn't you break
up the string at points you know to be non-dangerous? Namely, don't break it
in the middle of a tag. When you see a '<' character, set the boolean
isItSafeToBreakHere = false. When you see '>', set the boolean to true.

You might be able to set isItSafeToBreakHere to true when you see a ' '
(the space character) as well. This protects you against tags with a large
number of attributes which might overflow your buffer. I don't know if your
parser is flexible enough to accept this though.

- Oliver


.