[jdom-interest] reading xml from a socket

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue May 15 05:34:34 PDT 2001

I'm pretty sure that the inputstream must close for the build to end.  It
won't have anything to do with the content arriving on the inputstream.  As
a result, the parser will se the second root element and blow up because the
document is not well formed.  You will probably need to write your own
inputstream inplementation if the socket is going to stay open or perhaps
you could buffer and then call successive builds from a byte array or

> -----Original Message-----
> From: Jef Dodson [mailto:jcdodson at hotmail.com]
> Sent: Monday, May 14, 2001 8:23 PM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] reading xml from a socket
> Hello,
> I want to write some code that reads xml from a tcp/ip 
> socket.  The problem 
> is, what if the application on the other end of the socket 
> writes more than 
> one document to the socket's outputstream before my 
> application reads the 
> document from the inputstream?  Will the build() method be 
> smart enough to 
> build each document separately, or will it throw an exception 
> because it 
> looks like the document is not well formed?  For example, 
> suppose a client 
> sends two messages to a server in rapid succession before the 
> server app. 
> reads the data from the socket, so that the xml looks like 
> the following to 
> the server:
> <message id="1">
>     <type>text</type>
>     <body>Hello World</body>
> </message>
> <message id="2">
>     <type>text</type>
>     <body>Hello again</body>
> </message>
> Now, what happens when the builder.build() method is called?
> Thanks.
> Jef
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com

More information about the jdom-interest mailing list