How to write to a named pipe

A

Armin Gajda

Hi,

I have to write to a named pipe that was created by another
(VisualBasic) program. It is running all under Windows XP.

I have read it should work with an ordinary file operation, so I tried:

1: File file = new File("\\\\.\\pipe\\SamplePipe");
2: FileWriter fw = new FileWriter(file);
3: fw.write ("Hi folk!");
4: fw.close ();

and also with an FileOutputStream. But as soon as the second line is
executed, the external program terminates and I get the message:

java.io.FileNotFoundException: \\.\pipe\SamplePipe (Alle Pipeinstanzen
sind ausgelastet)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at java.io.FileWriter.<init>(FileWriter.java:73)

(The message's meaning in english: all pipe instances are busy)

So it knows that there is a pipe access, because if the external program
is not running it simply says 'file not found'.

If I use:

File file = new File("\\\\.\\pipe\\SamplePipe");
System.out.println("writable: " + file.canWrite ());

I get a true, and the external application terminates (what is actually
not wanted).

I use JDK 1.4.1_03.

Any hints?
 
E

EJP

Armin said:
1: File file = new File("\\\\.\\pipe\\SamplePipe");

Not sure about that dot: surely it should be a server name?
java.io.FileNotFoundException: \\.\pipe\SamplePipe (Alle Pipeinstanzen
sind ausgelastet)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at java.io.FileWriter.<init>(FileWriter.java:73)

(The message's meaning in english: all pipe instances are busy)

This just indicates a problem at the named-pipe server end. It isn't
executing ConnectNmPipe() or whatever the API is called these days (12
years since I have looked at this). This is a Windows issue not a Java
issue. (You can't program the server end in Java.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top