[comp.os.os2.programmer] Programming with named pipes, again

beng@microsoft.UUCP (Ben GOETTER) (02/11/91)

In article <1991Feb04.070011.7873@eecs.wsu.edu> wbonner@yoda.eecs.wsu.edu (Wim Bonner) writes:
| 
| when I do a DosMakeNmPipe() with the file name being "/pipe/dfa/config.dfa"
| everything works fine.  When I add the name of the server to the beginning as
| page 680 of the OS/2 Reference Vol.1 says to do, I go from getting a return
| value of "0" to a return value of "3" which indicates a bad filename.

DosMakeNmPipe only works locally; since you cannot create a named pipe on
another server, the API doesn't comprehend UNC notation.  Your server app
is correct to use /pipe/dfa/config.dfa, sans servername.

--
Ben Goetter, microsoft!beng

peter@hpuviea.UUCP (Peter Michalica) (02/12/91)

In article <1991Feb04.070011.7873@eecs.wsu.edu> wbonner@yoda.eecs.wsu.edu (Wim Bonner) writes:
>I've got my program that uses named pipes working wonderfully from local on my
>machine.
> ......
>when I do a DosMakeNmPipe() with the file name being "/pipe/dfa/config.dfa"
>everything works fine.  When I add the name of the server to the beginning as
>page 680 of the OS/2 Reference Vol.1 says to do, I go from getting a return
>value of "0" to a return value of "3" which indicates a bad filename.  (I
>think)
>Summary:
>
>"/pipe/dfa/config.dfa" returns 0 and works correctly.
>"/wimmer/pipe/config.dfa" returns 3 and doesn't work.
>"//wimmer/pipe/config.dfa" returns 3 and doesn't work.

The server program must always create the named pipe simply starting with
"/pipe/..." or for DOS and OS/2 more correct "\pipe\..." (as explained in the
MS OS/2 Programmer's reference). 
The client program specifies the name of the pipe it wants to connect in the
open call. Now if the program runs on the same machine it simply opens 
"\pipe\config.dfa", BUT if the program runs on a different machine, it
must also supply the machine name of the server: "\\wimmer\pipe\config.dfa".
In your case the with LanManager 2.0 running a peer server it might also work
that the client specifies the full name.

So keep in mind: 1. The server always creates "\pipe\dfa\config.dfa"
		 2. The client opens the pipe with either the above name or
		    with the server name in front.

By the way: There is a typo in the MS OS/2 Programmer's Reference Vol. 1
on page 680. The form for the remote pipe name is wrong, it should read:

\\server\pipe\name

Also keep in mind, that in C the character '\' is the escape character within
strings. So a call to would look like:

     DosMakeNmPipe("\\pipe\\name",....);

The client would call, for example:

     retval = DosOpen("\\\\wimmer\\pipe\\name",....);

I hope this helps.

Peter Michalica
HP Vienna