socket client reading string

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

socket client reading string

sugar_lisp
Hi

I have developed socket server in delphi and socket client in mozilla javascript. The server sends string data to socket client. I am not sure how to read it. I tried the following:


var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService(Components.interfaces.nsISocketTransportService);
var transport = transportService.createTransport(null,0,'127.0.0.1',4444,null);


var stream = transport.openInputStream(0,0,0);
var instream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
instream.init(stream);
var chunk = instream.read(512);
alert(chunk); // gives me blank, even though i send some string from the server


Please guide me and tell me what I am doing wrong.

Thank you.