Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone help me understand the problem with this chunk of code:
JavaScript
var file = Components.classes["@mozilla.org/file/local;1"]
           .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("\\\\.\\pipe\\MyPipe");
		
// WRITE
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);

// READ
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?
Posted
Updated 6-Mar-13 1:30am
v2

1 solution

I just came to realize that this is an unhandled BUG in Mozilla. Whenever you try to open an InputStream for reading from a NamedPipe, it throws a (NS_ERROR_FAILURE) EXCEPTION.

Hope they fix it soon though!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900