in reply to (tye)Re: How do I open a r/w named pipe as a file? *Should* be simple...
in thread How do I open a r/w named pipe as a file? *Should* be simple...

Grand, that works beautifully. I would not have opened Win32API::File on my own. Just to wrap it up, it looks like this, once fit to my program:

my $hPipe = createFile( $PIPE_NAME, "rwe" ) or die "Can't read from [$PIPE_NAME]: $^E\n"; $^E = 0; # Clear possibly misleading errors out. no strict 'subs'; OsFHandleOpen( PIPE, $hPipe, "rw" ) or die "Can't associate Perl handle: $! ($^E)\n"; use strict 'subs';
The 'e' portion of the "rwe" arg to createFile() causes an error if the file doesn't already exist, which is the behavior I want. If the pipe server isn't running, I need to know.

I expect there's a better way to quiet the complaint about the filehandle being a bareword, too.

Since I'm not reporting $^E unless there's an error, is it necessary to clear it ahead of time?

Thanks for the prompt answer to something that turned out trickier than I thought.

Replies are listed 'Best First'.
Re: Tye, that does the job.
by tye (Sage) on Mar 29, 2001 at 03:06 UTC

    Sorry, I forgot about that. OsFHandleOpen( \*PIPE, ... ) is what I would use.

            - tye (but my friends call me "Tye")
      Right, right, I remember that now. Haven't been slinging around filehandles before now.

      Sad to say, I spoke too soon. The piping isn't happy yet, the pipe server gets garbage characters at the end of the client's message, using this method. The client gets nothing but garbage in return. Think I'm going to take it home and mull it over.

        The OsFHandleOpen() part hasn't been exercised much at all so you can always try using ReadFile and WriteFile from that same module instead.

        Please give me details in case it is something about the module that I can fix. I just tried to use OsFHandleOpen in Win2K and it didn't work. ):

                - tye (but my friends call me "Tye")