NAME

IPC::Messaging - process handling and message passing, Erlang style

VERSION

This document describes IPC::Messaging version 0.01_07.

SYNOPSIS

 use IPC::Messaging;
 
 # Process creation
 my $proc = spawn {
   receive {
     got ping => then {
       print "$$: got ping from $_\n";
       $_->pong;
     };
   };
 };
 
 # Message sending
 $proc->ping;
 # Message matching
 receive {
   # matching message name
   got somemsg => then {
   };
   # matching message name and sender
   got pong => $proc => then {
   };
   # matching message name and content
   got msg => x => 1 => then {
   };
   # matching with a custom filter
   got msg => \&is_something => then {
   };
   # matching any message
   got _ => then {
     my ($message, $message_data, $from) = @_;
     print "$$: got $message from $from\n";
        # $_ is the same as $from:
     print "$$: got $_[0] from $_\n";
   };
   after 2 => then {
     print "$$: timeout\n";
   };
 };
 
 # TCP via message matching
 IPC::Messaging->tcp_server(1111);
 while (1) {
   receive {
     got tcp_connect => then {
       print "connect from $_[1]->{from}\n";
       print $_ "hi\n"; 
     };
     got tcp_data => then {
       print "got data: $_[1]->{data}\n";
     };
     got tcp_disconnect => then {
       print "disconnect from $_[1]->{from}\n";
     };
   };
 }

DESCRIPTION

This is a preliminary development version, and as such it is extremely poorly documented.

DEPENDENCIES

Perl 5.8.2 or above, B::Generate, JSON::XS.

INCOMPATIBILITIES

This module, in all likelihood, will only work on Unix-like operating systems.

BUGS AND LIMITATIONS

No bugs known. The API is a moving target. To be useful, reads from sockets in form of messages must be supported to a greater degree than they are now.

AUTHOR

Anton Berezin <tobez@tobez.org>

LICENSE AND COPYRIGHT

Copyright (c) 2007, Anton Berezin <tobez@tobez.org>. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.