Re: code does not work properly when i remove alert

Gijs Kruitbosch <[email protected]> Fri, 26 Feb 2010 10:25:22 +0100
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
On 26/02/2010 00:57 AM, sugar_lisp wrote:
>
> Hi
>
> I am facing a strange problem, in the code below when i remove alert
> statement the client socket does not send data to the server. I have read
> some forums on this problem and they mentioned about giving some time delay
> but it does not work.
>
> 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 outstream = transport.openOutputStream(0,0,0);
> alert('Sending Data'); //when i remove this statement the code does not work
> properly
>
> var len = y.length+'\n'+'';
> outstream.write(len,len.length);
> outstream.write(y,y.length);
> outstream.flush();
>
> Please do let me know the solution to this problem.

Define "Does not work properly"? Exception? Error message? Code runs fine but 
server doesn't get the data? What's going on?

 From reading the IDL, your problem may be solved by passing the OPEN_BLOCKING 
flag 
(http://mxr.mozilla.org/mozilla1.9.2/source/netwerk/base/public/nsITransport.idl#104), 
although I too don't know this code, and am just guessing. Try asking in 
m.d.platform instead (setting followupto). Alternatively, search for 
openOutputStream in MXR to find a working example.

~ Gijs