I think you are running into a socket programming issue more than anything
else.  I would set a flag in BinSockInputStream that gets signaled when you
get a short buffer.  If you ask for 1024 bytes and get 73 set the flag.
Check the flag on the way into readBytes to see if you are done or not.  

Otherwise you require some kind of transfer encoding scheme to tell when you
are done with the XML payload.  You may actually want ot look at
chunked-transfer-encoding...

Jim

> -----Original Message-----
> From: Norbert Kiesel [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 24, 2001 5:12 PM
> To: [EMAIL PROTECTED]
> Subject: parser trying to read twice
> 
> 
> 
> Hi,
> 
> I'm using Xerces (currently 1.4) to parse XML sent over a socket
> connection.  I've written a BinSockInputStream class which is derived
> from InputStream to feed the data into the parser.  In order to send
> more than one XML "file" over the same socket connection, I send a
> special illegal character (Ctrl-L) at the end of each XML "file" which
> is recognized (and removed) by BinSockInputStream.
> 
> Everything works beautifully besides one thing: the parser always
> calls BinSockInputStream::readBytes a second time after receiving the
> complete XML data. Example: if I get an XML which is shorter 
> than the size
> of the buffer passed to readBytes, I fill the buffer with the complete
> XML file.  Then, the parse function calls readBytes again.  At this
> point, I have no more data to return.
> 
> My first implementation just tried to read more data from the socket
> (and thus was blocked if this was the last XML "file").  Now I have a
> stupid flag in BinSockInputStream which just retuns 0 on every second
> invocation.  This seems to work, but is of course a gross hack.
> 
> So finally my question: -)
>   What do I have to do to tell the parser that it has got everything
>   and should not try to read more characters?
> 
> --nk
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to