Jihad,
I used Aminer's MemMap module to communicate and control a dozen FTP
processes. To help me do that I created another package called
ScalerShare.pm which ties selected scalers together using the MemMap module.
Talk about simple inter-script communication. I have included the test
script and the module if you want to try it. My thanks to Jan Dubois for
his assistance in removing the more glaring weaknessess. You can get
MemShare.pm from http://www.generation.net/~cybersky/Perl/.
Thanks,
Phil Larson
=======================================================
package ScalerShare;
use Win32::MemMap;
sub TIESCALAR
{
my $class = shift;
my $MemLoc = shift;
my $MemData = shift;
my $obj=new Win32::MemMap;
if ( $MemData )
{
$obj->OpenMem("//${MemLoc}",100)->Write(\${MemData},0);
}
return bless \$MemLoc, $class;
}
sub FETCH
{
my $self = shift;
my $MemLoc;
my $MemData;
my $obj=new Win32::MemMap;
my $mem=$obj->MapView("//$${self}",100,0);
if ( $mem and $mem->GetDataSize > 0)
{
$mem->Read(\$MemData,0,$mem->GetDataSize);
}
return $MemData;
}
sub STORE
{
my $self = shift;
my $MemData = shift;
my $obj=new Win32::MemMap;
my $mem=$obj->OpenMem("//$${self}",100);
if ( $mem )
{
$mem->Write(\$MemData,0);
}
else
{
$obj->OpenMem("//$${self}",100)->Write(\${MemData},0);
}
return $MemData;
}
1;
Here is "test.pl" which demonstrates its use. Start a half dozen of these up
from the command line and inter-process communicate away.
===================================================
#! /perl/bin/perl
use Misc::ScalerShare;
tie $a, 'ScalerShare', 'a', 'This is shared scaler $a';
print $a."\n";
print "Enter \"exit\" to exit script.\n\n";
while ($a ne "exit")
{
print "enter new \"\$a\" or nothing to read current value: ";
chomp($temp = <stdin>);
if ($temp) { $a = $temp;}
print $a."\n";
}
exit;
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Aldo Calpini
> Sent: Thursday, February 25, 1999 10:43 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [perl-win32-gui] Unblocking window state?
>
>
> Jihad Battikha wrote:
> >Hi,
> >
> >Please excuse me if this has already been asked numerous times on this
> >list (I'm new to the list).
> >
> >I'm trying to implement a very simple Win32::GUI application which is
> >able to listen on an open socket for incoming connection requests (this
> >problem doesn't *really* have to do with sockets, though). My problem
> >is that the script doesn't get to the socket code until the GUI is
> >destroyed or I outright call it with a UI action (button click or
> >something). The script does respond fine to UI actions but even when I
> >create a button to instantiate the socket code as a subroutine (instead
> >of being called at script execution), the socket code blocks and then I
> >can't use the UI until I kill the socket portion. :-(
>
>
> no luck, Jihad :-(
> you'll need a full blown multithreaded perl to do what you want within
> a single script... support for it is not yet mature, but it's in
> developement. the only resort is a two-script solution; you may eventually
> try with some Win32-specific interprocess communication mechanism
> (Mutex, Semaphore, Event, Shared memory, ...) to ensure that you can
> control your child script appropriately.
> HTH.
>
> cheers,
> Aldo Calpini
> <[EMAIL PROTECTED]>
>
>
>