Serilializing the DOM and passing through nsISocketTransportService.

stony_dreams <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Hello:

My extension serializes the DOM using the XMLSerilializer and then passes
the entire serialized string through an XPCOM socket over to a Java
application listening on that socket on the other end. This works fine when
the serialized string is small (For example for www.google.com), but when
this string is huge (For example for www.nytimes.com), the entire string
does not reach to the other end. That is, on the Java side I keep appending
the string read from this Socket stream untill I get a null; but I get this
null value even before the entire DOM has arrived. Following is my code:

JavaScript side: (Extension)
var transportService =
Components.classes["@mozilla.org/network/socket-transport-service;1"].getService(Components.interfaces.nsISocketTransportService);
var transport =
transportService.createTransport(null,0,"localhost",12335,null);
var outstream = transport.openOutputStream(0,0,0);

var oSerializable = new XMLSerializer();
var strGlob =
oSerializable.serializeToString(content.document.documentElement,
"application/xml");

outstream.write(strGlob, strGlob.length);
outstream.close();


JavaSide:
ServerSocket server = new ServerSocket(12335);
Socket client = server.accept();
BufferedReader socketReader = new BufferedReader(new
InputStreamReader(client.getInputStream()));
String domString = "";
String temp;

do{
temp = socketReader.readLine();
domString += temp;
}
while(temp != null);
socketReader.close();
}
client.close();

I appreciate any help with my problem.

Thanks...
-- 
View this message in context: http://www.nabble.com/Serilializing-the-DOM-and-passing-through-nsISocketTransportService.-tp14953816p14953816.html
Sent from the Mozilla - DOM mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.