How to write to a named pipe

Discussion in 'Java' started by Armin Gajda, Jul 28, 2006.

  1. Armin Gajda

    Armin Gajda Guest

    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?

    --
    bye Armin
     
    Armin Gajda, Jul 28, 2006
    #1
    1. Advertising

  2. Armin Gajda

    EJP Guest

    Armin Gajda wrote:
    >
    > 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.)
     
    EJP, Jul 29, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruintje Beer

    named pipe in java

    Bruintje Beer, Sep 27, 2005, in forum: Java
    Replies:
    2
    Views:
    9,110
    Roedy Green
    Sep 27, 2005
  2. rajnish

    c++ named pipe example

    rajnish, Oct 22, 2004, in forum: C++
    Replies:
    5
    Views:
    19,430
    John Harrison
    Oct 25, 2004
  3. lee, wonsun
    Replies:
    1
    Views:
    490
    Jack Klein
    Nov 2, 2004
  4. Jim Mozley
    Replies:
    6
    Views:
    163
    Jim Mozley
    Dec 1, 2003
  5. Replies:
    1
    Views:
    227
    Ben Morrow
    Jun 2, 2004
Loading...

Share This Page