Win32::Pipe - Win32 Named Pipe |
Win32::Pipe - Win32 Named Pipe
To use this extension, follow these basic steps. First, you need to 'use' the pipe extension:
use Win32::Pipe;
Then you need to create a server side of a named pipe:
$Pipe = Win32::Pipe->new("My Pipe Name");
or if you are going to connect to pipe that has already been created:
$Pipe = Win32::Pipe->new("\\\\server\\pipe\\My Pipe Name");
NOTE: The "\\\\server\\pipe\\" is necessary when connecting to an existing pipe! If you are accessing the same machine you could use "\\\\.\\pipe\\" but either way works fine.
You should check to see if $Pipe
is indeed defined otherwise there
has been an error.
Whichever end is the server, it must now wait for a connection...
$Result = $Pipe->Connect();
NOTE: The client end does not do this! When the client creates the pipe it has already connected!
Now you can read and write data from either end of the pipe:
$Data = $Pipe->Read();
$Result = $Pipe->Write("Howdy! This is cool!");
When the server is finished it must disconnect:
$Pipe->Disconnect();
Now the server could Connect
again (and wait for another client) or
it could destroy the named pipe...
$Data->Close();
The client should Close
in order to properly end the session.
This extension gives Win32 Perl the ability to use Named Pipes. Why?
Well considering that Win32 Perl does not (yet) have the ability to
fork
I could not see what good the pipe(X,Y)
was. Besides, where
I am as an admin I must have several perl daemons running on several
NT Servers. It dawned on me one day that if I could pipe all these
daemons' output to my workstation (across the net) then it would be
much easier to monitor. This was the impetus for an extension using
Named Pipes. I think that it is kinda cool. :)
And what are the benefits of this module?
ResizeBuffer
method.
All named pipes are byte streams. There is currently no way to alter a
pipe to be message based.
Other things that I cannot think of right now... :)
Returns true on success, false on failure.
ERROR_NUMBER
and ERROR_TEXT
.
SIZE
. Returns the size of the buffer on success, false on
failure.
DATA
to the named pipe. Returns true on success, false
on failure.
What known problems does this thing have?
Read
and the other end terminates then
you will wait for one REALLY long time! (If anyone has an idea on
how I can detect the termination of the other end let me know!)
All pipes are blocking. I am considering using threads and callbacks
into Perl to perform async IO but this may be too much for my time
stress. ;)
There is no security placed on these pipes.
This module has neither been optimized for speed nor optimized for
memory consumption. This may run into memory bloat.
If you wish to use this module with a build of Perl other than
ActivePerl, you may wish to fetch the source distribution for this
module. The source is included as part of the libwin32
bundle,
which you can find in any CPAN mirror here:
modules/by-authors/Gurusamy_Sarathy/libwin32-0.151.tar.gz
The source distribution also contains a pair of sample client/server test scripts. For the latest information on this module, consult the following web site:
http://www.roth.net/perl
Dave Roth <rothd@roth.net>
I do not guarantee ANYTHING with this package. If you use it you are doing so AT YOUR OWN RISK! I may or may not support this depending on my time schedule.
Copyright (c) 1996 Dave Roth. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Win32::Pipe - Win32 Named Pipe |