blob: 6ae585b7c9199f70c903889ea7fec69221f27f6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
use strict;
use Win32::Pipe;
####
# You may notice that named pipe names are case INsensitive!
####
my $PipeName = "\\\\.\\pipe\\TEST this LoNG Named Pipe!";
print "I am falling asleep for few seconds, so that we give time\nFor the server to get up and running.\n";
sleep(4);
print "\nOpening a pipe ...\n";
if (my $Pipe = Win32::Pipe->new($PipeName)) {
print "\n\nPipe has been opened, writing data to it...\n";
print "-------------------------------------------\n";
$Pipe->Write("\n" . Win32::Pipe::Credit() . "\n\n");
while () {
print "\nCommands:\n";
print " FILE:xxxxx Dumps the file xxxxx.\n";
print " Credit Dumps the credit screen.\n";
print " Quit Quits this client (server remains running).\n";
print " Exit Exits both client and server.\n";
print " -----------------------------------------\n";
my $In = <STDIN>;
chop($In);
if ((my $File = $In) =~ s/^file:(.*)/$1/i){
if (-s $File) {
if (open(FILE, "< $File")) {
while ($File = <FILE>) {
$In .= $File;
};
close(FILE);
}
}
}
if ($In =~ /^credit$/i){
$In = "\n" . Win32::Pipe::Credit() . "\n\n";
}
unless ($Pipe->Write($In)) {
print "Writing to pipe failed.\n";
last;
}
if ($In =~ /^(exit|quit)$/i) {
print "\nATTENTION: Closing due to user request.\n";
last;
}
}
print "Closing...\n";
$Pipe->Close();
}
else {
my($Error, $ErrorText) = Win32::Pipe::Error();
print "Error:$Error \"$ErrorText\"\n";
sleep(4);
}
print "Done...\n";
|