How to send XML data through socket InputStream
Posted
by THeK3nger
on Stack Overflow
See other posts from Stack Overflow
or by THeK3nger
Published on 2009-09-15T15:58:22Z
Indexed on
2010/03/14
9:45 UTC
Read the original article
Hit count: 186
Hi,
I'm trying to write a client-server application in Java with an XML-based protocol. But I have a great problem! See this part of client code:
InputStream incoming = skt.getInputStream(); //I get Stream from Socket.
OutputStream out = skt.getOutputStream();
[...]
XMLSerializer serializer = new XMLSerializer();
//This create an XML document.
tosend = WUTPClientWriter.createMessage100(projectid, cpuclock, cpunumber);
serializer.setOutputByteStream(out);
serializer.serialize(tosend);
At this point server fall in deadlock. It wait for EOF but I can't send it because if I use
out.close();
or
skt.shutdownOutput();
I close Socket and I must keep alive this connection.
I can't send '\0' becouse I get Parse Error in the server.
How can I do? Can I "close" output stream without close socket?
RESOLVED I've created new class XMLStreamOutput and XMLStreamInput with advanced Stream gesture.
© Stack Overflow or respective owner