Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
socket\KeepSocketOpen.java - Apache Xerves Socket Sample
What is the socket\KeepSocketOpen.java provided in the Apache Xerces package? I have Apache Xerces 2.11.0 installed.
✍: FYIcenter
socket\KeepSocketOpen.java provided in the Apache Xerces package provides a solution to the problem of 1) sending multiple XML documents over a single socket connection or 2) sending other types of data after the XML document without closing the socket connection.
The first situation is a problem because the XML specification does not allow a document to contain multiple root elements. Therefore a document stream must end (or at least appear to end) for the XML parser to accept it as the end of the document.
The second situation is a problem because the XML parser buffers the input stream in specified block sizes for performance reasons. This could cause the parser to accidentally read additional bytes of data beyond the end of the document. This actually relates to the first problem if the documents are encoding in two different international encodings.
The solution that this sample introduces wraps both the input and output stream on both ends of the socket. The stream wrappers introduce a protocol that allows arbitrary length data to be sent as separate, localized input streams. While the socket stream remains open, a separate input stream is created to "wrap" an incoming document and make it appear as if it were a standalone input stream.
Here is how to run socket\DelayedInput.java, if you have Apache Xerces 2.11.0 installed:
\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\javac -cp ..\xercesImpl.jar;..\xercesSamples.jar socket\KeepSocketOpen.java Note: socket\KeepSocketOpen.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. C:\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java -cp .;..\xercesImpl.jar;..\xercesSamples.jar socket.KeepSocketOpen User.xml UserDTD.xml UserXSD.xml Server: Created. Client: Created. Server: Running. Client: Running. Server: Client connected. Server: Opening file "User.xml" Server: Wrote 226 byte(s) total. Server: Opening file "UserDTD.xml" Server: Wrote 411 byte(s) total. Server: Opening file "UserXSD.xml" Server: Wrote 411 byte(s) total. Server: Exiting. Client: Read 226 byte(s) total. Client: 2 ms (5 elems, 0 attrs, 0 spaces, 58 chars) Client: Read 411 byte(s) total. Client: 6 ms (5 elems, 0 attrs, 21 spaces, 37 chars) Client: Read 411 byte(s) total. Client: 2 ms (5 elems, 3 attrs, 0 spaces, 62 chars) Client: Exiting.
⇒ Using Apache Xerces Other Sample Programs
⇐ Read XML with Schema from Socket with socket\DelayedInput.java
2017-09-20, 12571🔥, 0💬
Popular Posts:
What Is HttpComponents httpcore-4.4.6.jar? HttpComponents httpcore-4.4.6.jar is the JAR file for Apa...
MXP1 is a stable XmlPull parsing engine that is based on ideas from XPP and in particular XPP2 but c...
Apache Log4j SLF4J Binding allows applications coded to the SLF4J API to use Log4j 2 as the implemen...
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...
Provides support for the runtime platform, core utility methods and the extension registry. JAR File...