Can anyone help me understand the problem with this chunk of code:
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("\\\\.\\pipe\\MyPipe");
var myRequest = "BlaBla";
var outputStream = Components.classes["@mozilla.org/network/file-outputstream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
outputStream.init(file, 0x02 | 0x08, -1, 0);
outputStream.write(myRequest, myRequest.length);
var result;
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
inputStream.init(file, -1, 0, 0);
inputStream.read(result);
As you might have already guessed, I am trying to open a named pipe, send some information, and receive some info. The sending part works. However, it stops for some reason at the reading part and i get nothing!
Any ideas?
UPDATE: I just figured out the reason why its acting strange, for some reason I can't add an
InputStream
and an
OutputStream
to the same pipe. When i try adding an
outputstream
and writing to it
ONLY, it seems to work just fine. However, as soon as i add my
InputStream
, it stalls for some reason.
Any ideas Why this occurs?