ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-FDPass/FDPass.pm
(Generate patch)

Comparing IO-FDPass/FDPass.pm (file contents):
Revision 1.7 by root, Sat Apr 6 22:10:56 2013 UTC vs.
Revision 1.8 by root, Sat Apr 6 22:26:41 2013 UTC

14 14
15=head1 DESCRIPTION 15=head1 DESCRIPTION
16 16
17This small low-level module only has one purpose: pass a file descriptor 17This small low-level module only has one purpose: pass a file descriptor
18to another process, using a (streaming) unix domain socket (on POSIX 18to another process, using a (streaming) unix domain socket (on POSIX
19systems) or any (streaming) socket (on WIN32 systems). 19systems) or any (streaming) socket (on WIN32 systems). The ability to pass
20file descriptors on windows is currently the unique selling point of this
21module. Have I mentioned that it is really small, too?
20 22
21=head1 FUNCTIONS 23=head1 FUNCTIONS
22 24
23=over 4 25=over 4
24 26
53=item $fd = IO::FDPass::recv $socket_fd 55=item $fd = IO::FDPass::recv $socket_fd
54 56
55Receive a file descriptor from the socket and return it if successful. On 57Receive a file descriptor from the socket and return it if successful. On
56errors, return C<-1>. 58errors, return C<-1>.
57 59
58Note that I<both> C<$socket_fd> amd the returned file descriptor are, in 60Note that I<both> C<$socket_fd> and the returned file descriptor are, in
59fact, file descriptors, not handles. 61fact, file descriptors, not handles.
60 62
61When used on non-blocking sockets, this function might fail with C<$!> 63When used on non-blocking sockets, this function might fail with C<$!> set
62set to C<EAGAIN> or equivalent, in which case you are free to try. It 64to C<EAGAIN> or equivalent, in which case you are free to try again. It
63should succeed if called on a socket that indicates readability (e.g. via 65should succeed if called on a socket that indicates readability (e.g. via
64C<select>). 66C<select>).
65 67
66Example: receive a file desriptor from a blockign socket and convetr it to 68Example: receive a file descriptor from a blocking socket and convert it
67a file handle. 69to a file handle.
68 70
69 my $fd = IO::FDPass::recv fileno $socket; 71 my $fd = IO::FDPass::recv fileno $socket;
70 $fd >= 0 or die "unable to receive file handle: $!"; 72 $fd >= 0 or die "unable to receive file handle: $!";
71 open my $fh, "+<&=$fd" 73 open my $fh, "+<&=$fd"
72 or die "unable to convert file descriptor to handle: $!"; 74 or die "unable to convert file descriptor to handle: $!";
106and it's author didn't respond to my mail with the fix, so doesn't work on 108and it's author didn't respond to my mail with the fix, so doesn't work on
107many 64 bit machines. It does, however, support a number of pre-standard 109many 64 bit machines. It does, however, support a number of pre-standard
108unices, basically everything of relevance at the time it was written. 110unices, basically everything of relevance at the time it was written.
109 111
110The latter seems to have similar support for antique unices, and doesn't 112The latter seems to have similar support for antique unices, and doesn't
111seem to suffer from 64 bit bugs, but inexplicably has a large perl part, 113seem to suffer from 64 bit bugs, but inexplicably has a large perl
114part, doesn't support mixing data and file descriptors, and requires
112and requires AnyEvent. Presumably that makes it much more user friendly 115AnyEvent. Presumably that makes it much more user friendly than this
113than this module (skimming the manpage shows that a lot of thought has 116module (skimming the manpage shows that a lot of thought has gone into
114gone into it, and you are well advised to read it and maybe use it before 117it, and you are well advised to read it and maybe use it before trying a
115trying a low-level module such as this one). 118low-level module such as this one). In fact, the manpage discusses even
119more file descriptor passing modules on CPAN.
116 120
117Neither seems to support native win32 perls. 121Neither seems to support native win32 perls.
118 122
119=head1 AUTHOR 123=head1 AUTHOR
120 124

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines