[jdom-interest] Re: passing doc through socket

Joseph Bowbeer jozart at csi.com
Thu Nov 16 06:25:05 PST 2000


I tracked down the problem I was having passing a document through a
socket.

The problem is that several XML parsers *close* the input stream when
they read eof (-1).

This is true of Xerces, which is JDOM's default parser.  It is also true
of Crimson.

  org.apache.xerces.readers.UTF8Reader
  org.apache.crimson.parser.InputEntity

Unfortunately, closing a SocketInputStream closes the underlying
SocketImpl, setting the file descriptor to null.

To workaround, protect your socket's input stream with an InputStream
wrapper that doesn't close the underlying stream, or read everything
into a buffer before handing off to the JDOM builder.

  byte[] buf = new byte[length];
  new DataInputStream(inputStream).readFully(buf);
  InputStream in = new ByteArrayInputStream(buf);


----- original message -----

Alex Brud alex at ispfocus.com
Wed, 18 Oct 2000 14:49:37 +0200

i'm trying to path a document converted to outputStream through a
server-socket application.

to send the document im using (at the client end):
 XMLOutputter outputter = new XMLOutputter();
 outputter.output(doc,out) as 'out' == ItsSocket.getOutputStream;

to receve the stream , im using (at the server end):
 DOMBuilder builder = new DOMBuilder();
 doc = builder.build(itsSocket.getinputStream);

but it seems that the process is "stuck" when building the document.
the process never get beyong the builder line.






More information about the jdom-interest mailing list