use Win32::Pipe; use strict; my $PipeName = "com2"; my $Pipe; $| = 1; my $bServerContinue = 1; print "Creating pipe \"$PipeName\".\n"; if( $Pipe = new Win32::Pipe( $PipeName ) ) { while( $bServerContinue ) { print "Waiting for a client to connect...\n"; if( $Pipe->Connect() ) { my $In; my $User = ( $Pipe->GetInfo() )[2]; print "Pipe opened by $User.\n"; $In = $Pipe->Read(); print "Client sent us: $In"; print "Disconnecting...\n"; $Pipe->Disconnect(); } } $Pipe->Close(); } else { print "\nCould not create pipe\n"; print "Error: " . Win32::FormatMessage( $Win32::Pipe::Error ) . "\n"; } #### sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; #reset $! to zero to reset any current errors. local $! = 0; $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { # Added by JOC 06-APR-96 # $pack = 0; $pack = 0; ($pack,$file,$line) = caller; print "Your vendor has not defined Win32::Pipe macro $constname, used in $file at line $line."; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; }