Dave Lambley > Linux-PipeMagic-0.03 > Linux::PipeMagic

Download:
Linux-PipeMagic-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Linux::PipeMagic - Perl extension to use the zero copy IO syscalls

SYNOPSIS ^

  use Linux::PipeMagic qw/ systee syssplice /;
  systee($fh_in, $fh_out, $num_bytes, 0);
  syssplice($fh_in, $fh_out, $num_bytes, 0);

DESCRIPTION ^

Linux::PipeMagic is a Perl XS wrapper around the splice(2) and tee(2) syscalls. You can use them to efficiently data from one file descriptor to another inside the kernel (splice), or to efficiently copy data from one pipe to another (tee).

FUNCTIONS ^

sysplice($fh_in, $fh_out, $num_bytes, $flags)

Moves $num_bytes from $fh_in to $fh_out. This is roughly equivilent to,

    sysread($fh_in, my $buf, $num_bytes);
    syswrite($fh_out, $buf);

although the transfer takes place entirely in kernel-space.

Returns the number of bytes transferred.

systee($fh_in, $fh_out, $num_bytes, $flags)

Copies $num_bytes from $fh_in to $fh_out. The filehandles must both be of pipes. This works similarly to syssplice, but does not advance the read pointer in $fh_in.

Returns the number of bytes transferred.

CONSTANTS ^

SEE ALSO ^

See the Linux manpages for more details on how splice and tee can be used, including the flags.

AUTHOR ^

Dave Lambley, <cpan@davel.org.uk>

COPYRIGHT AND LICENSE ^

Copyright (C) 2011 by Dave Lambley

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: