How to send XML data through socket InputStream
- by THeK3nger
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.