Actually olive, using a delimiter isn't feasible as many times we need to transfer binary data. There is a possibility of the delimiter being present in the ACTUAL_DATA.
So, your first option looks the best but then again it's not possible to serialize the whole data before sending because there are chances of memory segmentation happening when no.of records are huge. So we are planning to add the following modifications to our protocol:-
1) Reading from the database, forming the XML and then sending over the socket.....everything will happen frame by frame as told by you.
2) Each frame will have the usual HEADER containing the length of ACTUAL_DATA present in that particular frame.
3) Modification:- The first frame will have the additional info of the TOTAL NO.OF RECORDS that we would be send gradually. So at the receiver end we would keep looping until the no.of parsed records becomes equal to the value present in the HEADER of first frame.
4) I am planning to skip the following step suggested by you. I hope this shouldn't be an issue:-
streamWriter.writeStartDocument();
streamWriter.writeEndDocument();
Reason- I don't want the following header in my XML: <?xml version="1.0" encoding="UTF-8"?>
streamWriter.writeStartDocument();
streamWriter.writeEndDocument();
Reason- I don't want the following header in my XML: <?xml version="1.0" encoding="UTF-8"?>
To copy to clipboard, switch view to plain text mode
Bookmarks