Chinaunix首页 | 论坛 | 博客
  • 博客访问: 599953
  • 博文数量: 60
  • 博客积分: 3993
  • 博客等级: 中校
  • 技术积分: 1572
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 17:08
文章分类

全部博文(60)

文章存档

2012年(7)

2011年(35)

2010年(8)

2009年(7)

2008年(3)

分类:

2008-10-21 16:56:37

#!/usr/bin/perl -w

#test_server run under administrator
use strict;
use IPC::Shareable;
my $glue = 'test.key';
my %options = (
    create => 1,
    exclusive => 0,
    mode => 0644,
    destroy => 1,
);
my @arr;
tie @arr, 'IPC::Shareable', $glue, { %options } or die "server: tie failed\n";
@arr = ();
while (1) {
        print "Input:";
        my $input=<STDIN>;
        chomp $input;
        if (defined $input) {
                push(@arr,$input);
        }
        print "\@arr:@arr\n";
}
exit;


 

 

#!/usr/bin/perl -w

#test_client run under administrator

use strict;
use IPC::Shareable;
my $glue = 'test.key';
my %options = (
    create => 0,
    exclusive => 0,
    mode => '0644',
    destroy => 0,
    size=>65536 #size must less then 65536
    );
my @arr;
my $ipch=tie @arr, 'IPC::Shareable', $glue, { %options } or die "client: tie failed\n";
while(1) {
        if (scalar @arr > 0) {
                $ipch->shlock;
                my $str=shift @arr;
                $ipch->shunlock;
                print "output:$str\n";
        } else {
                sleep 3;
        }
}
exit;

阅读(1300) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~