File Coverage

blib/lib/IO/FDpassData.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 9 88.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             package IO::FDpassData;
3             #
4 10     10   1930226 use strict;
  10         98  
  10         312  
5             #use diagnostics;
6              
7 10     10   44 use vars qw($VERSION @ISA @EXPORT);
  10         18  
  10         1454  
8              
9             require Exporter;
10              
11             $VERSION = do { my @r = (q$Revision: 0.03 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
12              
13             @EXPORT = qw(
14             fd_sendata
15             fd_recvdata
16             );
17              
18             require DynaLoader;
19             @ISA = qw(Exporter DynaLoader);
20             bootstrap IO::FDpassData $VERSION;
21              
22       0     sub DESTROY {};
23              
24             =head1 NAME
25              
26             IO::FDpassData - send/receive data and/or file descriptor
27              
28             =head1 SYNOPSIS
29              
30             use IO::FDpassData;
31              
32             $bytessent = fd_sendata(socket, message, FD);
33              
34             ($bytesrcvd, message, FD) = fd_rcvdata(socket, $maxsize);
35              
36             =head1 DESCRIPTION
37              
38             This module will send and receive data and/or a file descriptor locally over a unix pipe.
39              
40             =over 2
41              
42             =item * $bytessent = fd_sendata(socket, message, FD);
43              
44             input: socket file descriptor,
45             {optional} message, may be zero length string
46             {optional} file descriptor to send to other process
47              
48             NOTE: optional message may be 'undef' or zero length string
49             optional FD may be omitted, 'undef'
50              
51             returns: bytes sent
52             or -1 on error
53              
54             =item * ($bytesrcvd, message, FD) = fd_rcvdata(socket, $maxsize);
55              
56             input: socket file descriptor,
57             maximum length to receive overrun will cause segfault??
58              
59             returns: msg bytes received, or -1 on error
60             message, may be zero a length string
61             {optional} file descriptor or undef
62              
63             =back
64              
65             =head1 EXPORTS
66              
67             fd_sendata
68             fd_recvdata
69              
70             =head1 COPYRIGHT
71              
72             Copyright Michael Robinton 2019
73              
74             =head1 CREDITS
75              
76             This package was inspired by an article published by Keith Packard https://keithp.com/blogs/fd-passing/
77             and the package IO::FDpass written by Marc A. Lehmann
78              
79             =head1 SHORTCOMINGS
80              
81             At the present time this package does not support Windows. Patches welcome.
82              
83             =head1 LICENSE
84              
85             This is free software; you can redistribute it and/or modify it under the terms of either:
86              
87             a) the GNU General Public License as published by the Free Software
88             Foundation; either version 1, or (at your option) any later version, or
89              
90             b) the "Artistic License".
91              
92             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
93             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
94             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
95             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
96             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
97             FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
98             IN THE SOFTWARE.
99              
100             =cut
101              
102             1;