splice-0.6.0.2: Cross-platform Socket to Socket Data Splicing

Safe HaskellSafe-Infered

System.IO.Splice.Linux

Description

Exposes the GNU/Linux system call splice(): http://kerneltrap.org/node/6505.

This module is only available (compiled & exposed) on GNU/Linux.

Synopsis

Documentation

c_spliceSource

Arguments

:: Fd

fd_in.

-> Ptr Int64

off_in.

-> Fd

fd_out.

-> Ptr Int64

off_out.

-> ChunkSize

len.

-> Word

flags.

-> IO Int32

number of bytes moved if successful; otherwise -1.

Moves data between two file descriptors without copying between kernel address space and user address space. It transfers up to len bytes of data from the file descriptor fd_in to the file descriptor fd_out, where one of the descriptors must refer to a pipe.

c_splice is NOT a loop and needs to be called repeatedly.

For an example, see splice.

type ChunkSize = Word32Source

The numeric type used by c_splice for chunk size recommendations when moving data.

sPLICE_F_MOVE :: WordSource

Attempt to move pages instead of copying. This is only a hint to the kernel: pages may stil be copied (in kernel address space) if the kernel cannot move the pages from the pipe, or if the pipe buffers don't refer to full pages.

sPLICE_F_MORE :: WordSource

More data will be coming in a subsequent c_splice. This is a helpful hint when fd_out refers to a socket.

sPLICE_F_NONBLOCK :: WordSource

Do not block on I/O. This makes the c_splice pipe operations nonblocking, but c_splice may nevertheless block because the file descriptors that are c_spliced to/from may block (unless they have the O_NONBLOCK flag set).