Re: code does not work properly when i remove alert

Pavol Mišík <[email protected]> Fri, 26 Feb 2010 09:44:40 +0100
Newsgroups gmane.comp.mozilla.devel.jsdebugger
Message-ID <[email protected]>
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.

Honestly I never used it.
But taking a look at
http://mxr.mozilla.org/mozilla1.9.2/source/netwerk/base/public/nsISocketTransport.idl#47

If I were you I would try to write you own class that implements 
nsITransportEventSink, set it to transport, by setEventSink before you 
call openOutputStream and then wait till you get status STATUS_CONNECTED_TO.

PM-