-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Cross platform library for the sendfile system call. This library
--   tries to call minimum system calls which are the bottleneck of web
--   servers.
@package simple-sendfile
@version 0.2.33


-- | Cross platform library for the sendfile system call. This library
--   tries to call minimum system calls which are the bottleneck of web
--   servers.
module Network.Sendfile

-- | Simple binding for sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- open(), stat(), sendfile(), and close()</li>
--   <li>PartOfFile -- open(), sendfile(), and close()</li>
--   </ul>
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO ()

-- | Simple binding for send() and sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- open(), send(), stat(), sendfile(), and close()</li>
--   <li>PartOfFile -- open(), send(), sendfile(), and close()</li>
--   </ul>
--   
--   The fifth header is sent with send() + the MSG_MORE flag. If the file
--   is small enough, the header and the file is send in a single TCP
--   packet.
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO ()

-- | Simple binding for sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- stat() and sendfile()</li>
--   <li>PartOfFile -- sendfile()</li>
--   </ul>
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfileFd :: Socket -> Fd -> FileRange -> IO () -> IO ()

-- | Simple binding for send() and sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- send(), stat() and sendfile()</li>
--   <li>PartOfFile -- send() and sendfile()</li>
--   </ul>
--   
--   The fifth header is sent with send() + the MSG_MORE flag. If the file
--   is small enough, the header and the file is send in a single TCP
--   packet.
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfileFdWithHeader :: Socket -> Fd -> FileRange -> IO () -> [ByteString] -> IO ()

-- | File range for <tt>sendfile</tt>.
--   
--   <ul>
--   <li>If the offset or the length of <a>PartOfFile</a> is negative, an
--   <a>IOException</a> of <a>InvalidArgument</a> is thrown before anything
--   is sent.</li>
--   <li>If the length is 0, nothing is sent (only the header for the
--   <tt>WithHeader</tt> variants).</li>
--   <li>If the file is shorter than the range, or is truncated while being
--   sent, sending stops at the end of the file without any error. So, the
--   number of bytes sent may be less than requested.</li>
--   </ul>
data FileRange
EntireFile :: FileRange
PartOfFile :: Integer -> Integer -> FileRange
[rangeOffset] :: FileRange -> Integer
[rangeLength] :: FileRange -> Integer

module System.Linux.Sendfile

-- | Simple binding for sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- open(), stat(), sendfile(), and close()</li>
--   <li>PartOfFile -- open(), sendfile(), and close()</li>
--   </ul>
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfile :: Fd -> ByteString -> FileRange -> IO () -> IO ()

-- | Simple binding for sendfile() of Linux. Used system calls:
--   
--   <ul>
--   <li>EntireFile -- stat() and sendfile()</li>
--   <li>PartOfFile -- sendfile()</li>
--   </ul>
--   
--   If the size of the file is unknown when sending the entire file,
--   specifying PartOfFile is much faster.
--   
--   The fourth action argument is called when a file is sent as chunks.
--   Chucking is inevitable if the socket is non-blocking (this is the
--   default) and the file is large. The action is called after a chunk is
--   sent and before waiting the socket to be ready for writing.
sendfileFd :: Fd -> Fd -> FileRange -> IO () -> IO ()

-- | File range for <tt>sendfile</tt>.
--   
--   <ul>
--   <li>If the offset or the length of <a>PartOfFile</a> is negative, an
--   <a>IOException</a> of <a>InvalidArgument</a> is thrown before anything
--   is sent.</li>
--   <li>If the length is 0, nothing is sent (only the header for the
--   <tt>WithHeader</tt> variants).</li>
--   <li>If the file is shorter than the range, or is truncated while being
--   sent, sending stops at the end of the file without any error. So, the
--   number of bytes sent may be less than requested.</li>
--   </ul>
data FileRange
EntireFile :: FileRange
PartOfFile :: Integer -> Integer -> FileRange
[rangeOffset] :: FileRange -> Integer
[rangeLength] :: FileRange -> Integer
