]> git.vpit.fr Git - perl/modules/IPC-MorseSignals.git/blob - README
Importing IPC-MorseSignals-0.02.tar.gz
[perl/modules/IPC-MorseSignals.git] / README
1 NAME
2     IPC::MorseSignals - Communicate between processes with Morse signals.
3
4 VERSION
5     Version 0.02
6
7 SYNOPSIS
8         use IPC::MorseSignals qw/msend mrecv/;
9
10         my $pid = fork;
11         if (!defined $pid) {
12          die "fork() failed: $!";
13         } elsif ($pid == 0) {
14          local @SIG{qw/USR1 USR2/} = mrecv sub {
15           print STDERR "received $_[0]!\n";
16           exit
17          };
18          1 while 1;
19         }
20         msend "hello!\n" => $pid;
21         waitpid $pid, 0;
22
23 DESCRIPTION
24     This module implements a rare form of IPC by sending Morse-like signals
25     through "SIGUSR1" and "SIGUSR2". Both of those signals are used, so you
26     won't be able to keep them for something else when you use this module.
27
28     But, seriously, use something else for your IPC. :)
29
30 FUNCTIONS
31   "msend"
32         msend $msg, $pid [, $speed ]
33
34     Sends the string $msg to the process $pid (or to all the processes @$pid
35     if $pid is an array ref) at $speed bits per second. Default speed is
36     512, don't set it too low or the target will miss bits and the whole
37     message will be crippled.
38
39   "mrecv"
40         mrecv $callback
41
42     Takes as its sole argument the callback triggered when a complete
43     message is received, and returns two code references that should replace
44     SIGUSR1 and SIGUSR2 signal handlers. Basically, you want to use it like
45     this :
46
47         local @SIG{qw/USR1 USR2/} = mrecv sub { ... };
48
49 EXPORT
50     This module exports on request its two only functions, "msend" and
51     "mrecv".
52
53 PROTOCOL
54     Each byte of the data string is converted into its bits sequence, with
55     bits of highest weight coming first. All those bits sequences are put
56     into the same order as the characters occur in the stream. The emitter
57     computes then the longuest sequence of successives 0 (say, "m") and 1
58     ("n"). A signature is then chosen :
59
60     If C(m > n), we take "n+1" times 1 follewed by 1 0 ;
61     Otherwise, we take "m+1" times 0 follewed by 1 1.
62
63     The signal is then formed by concatenating the signature, the data bits
64     and the reversed signature (i.e. the bits of the signature in the
65     reverse order).
66
67     The receiver knows that the signature has been sent when it has catched
68     at least one 0 and one 1. The signal is completely transferred when it
69     has received for the first time the whole reversed signature.
70
71 CAVEATS
72     This type of IPC is highly unreliable. Send little data at slow speed if
73     you want it to reach its goal.
74
75     SIGUSR{1,2} seem to interrupt sleep, so it's not a good idea to transfer
76     data to a sleeping process.
77
78 DEPENDENCIES
79     POSIX (standard since perl 5) and Time::HiRes (standard since perl
80     5.7.3) are required.
81
82 SEE ALSO
83     perlipc for information about signals in perl.
84
85     For truely useful IPC, search for shared memory, pipes and semaphores.
86
87 AUTHOR
88     Vincent Pit, "<perl at profvince.com>"
89
90     You can contact me by mail or on #perl @ FreeNode (Prof_Vince).
91
92 BUGS
93     Please report any bugs or feature requests to "bug-ipc-morsesignals at
94     rt.cpan.org", or through the web interface at
95     <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-MorseSignals>. I
96     will be notified, and then you'll automatically be notified of progress
97     on your bug as I make changes.
98
99 SUPPORT
100     You can find documentation for this module with the perldoc command.
101
102         perldoc IPC::MorseSignals
103
104 ACKNOWLEDGEMENTS
105     Thanks for the inspiration, mofino ! I hope this module will fill all
106     your IPC needs. :)
107
108 COPYRIGHT & LICENSE
109     Copyright 2007 Vincent Pit, all rights reserved.
110
111     This program is free software; you can redistribute it and/or modify it
112     under the same terms as Perl itself.
113