<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Network.Socket.SendFile</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Network-Socket-SendFile.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Network-Socket-SendFile.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">sendfile-0.7.6: A portable sendfile library</p></div><div id="content"><div id="module-header"><p class="caption">Network.Socket.SendFile</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Safe functions (recommended) </a></li><li><a href="#g:2">Unsafe functions </a></li><li><a href="#g:3">Utility functions </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A cross-platform wrapper for sendfile -- this implements an available operating-system call if supported, otherwise it falls back to a portable haskell implementation. </p><p>Two interfaces are provided for both the unsafe and safe sets of functions. The first interface accepts an output socket/handle and the path of the file you want to send; sendFile and unsafeSendFile comprise this interface. The second interface accepts an output socket/handle, a handle to the file you want to send, an offset, and the number of bytes you want to send; sendFile' and unsafeSendFile' comprise this interface. </p><p>For consistent read/write behavior with either sendFile' or unsafeSendFile', the input handle should be opened in Binary mode rather than Text mode. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">type</span> <a href="#t:ByteCount">ByteCount</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Integer">Integer</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Offset">Offset</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Integer">Integer</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Iter">Iter</a> <ul class="subs"><li>= <a href="#v:Sent">Sent</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a>) </li><li>| <a href="#v:WouldBlock">WouldBlock</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a>) </li><li>| <a href="#v:Done">Done</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a> </li></ul></li><li class="src short"><a href="#v:runIter">runIter</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a></li><li class="src short"><a href="#v:sendFile">sendFile</a> :: <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:sendFileIterWith">sendFileIterWith</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:sendFile-39-">sendFile'</a> :: <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:sendFileIterWith-39-">sendFileIterWith'</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:unsafeSendFile">unsafeSendFile</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:unsafeSendFileIterWith">unsafeSendFileIterWith</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:unsafeSendFile-39-">unsafeSendFile'</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:unsafeSendFileIterWith-39-">unsafeSendFileIterWith'</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a> -> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:sendFileMode">sendFileMode</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:ByteCount" class="def">ByteCount</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Integer">Integer</a><a href="src/Network-Socket-SendFile.html#ByteCount" class="link">Source</a></p><div class="doc"><p>The length (in bytes) which should be sent </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Offset" class="def">Offset</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Prelude.html#t:Integer">Integer</a><a href="src/Network-Socket-SendFile.html#Offset" class="link">Source</a></p><div class="doc"><p>The file offset (in bytes) to start from </p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Iter" class="def">Iter</a> <a href="src/Network-Socket-SendFile-Iter.html#Iter" class="link">Source</a></p><div class="doc"><p>An iteratee for sendfile </p><p>In general, a whole file is not sent by a single call to sendfile(), but a series of calls which send successive pieces. </p><p>The high-level API in this sendfile library has calls which will send the entire file (or an entire requested offset+length), before returning. </p><p>However, there are instances where you want to be a bit more involved in the sending loop. For example, if you want to tickle a timeout after each chunk is sent or update a progress bar. </p><p>The <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> type gives you that power with out requiring you to manage all the low-level details of the sendfile loop. The interface is simple and consistant across all platforms. </p><p>A call to sendfile() can result in three different states: </p><ol><li> the requested number of bytes for that iteration was sent successfully, there are more bytes left to send. </li><li> some (possibly 0) bytes were sent, but the file descriptor would now block if more bytes were written. There are more bytes left to send. </li><li> All the bytes were sent, and there is nothing left to send. </li></ol><p>We handle these three cases by using a type with three constructors: </p><pre> data Iter = Sent Int64 (IO Iter) | WouldBlock Int64 Fd (IO Iter) | Done Int64 </pre><p>All three constructors provide an <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a></code> which represents the number of bytes sent for that particular iteration. (Not the total byte count). </p><p>The <code><a href="Network-Socket-SendFile.html#v:Sent">Sent</a></code> and <code><a href="Network-Socket-SendFile.html#v:WouldBlock">WouldBlock</a></code> constructors provide <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a></code> <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> as their final argument. Running this IO action will send the next block of data. </p><p>The <code><a href="Network-Socket-SendFile.html#v:WouldBlock">WouldBlock</a></code> constructor also provides the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a></code> for the output socket. You should not send anymore data until the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a></code> would not block. The easiest way to do that is to use <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Control-Concurrent.html#v:threadWaitWrite">threadWaitWrite</a></code> to suspend the thread until the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a></code> is available. </p><p>A very simple function to drive the Iter might look like: </p><pre> runIter :: IO Iter -> IO () runIter iter = do r <- iter case r of (Done _n) -> return () (Sent _n cont) -> runIter cont (WouldBlock _n fd cont) -> do threadWaitWrite fd runIter cont </pre><p>You would use it as the first argument to a *IterWith function, e.g. </p><pre> sendFileIterWith runIter outputSocket "/path/to/file" 2^16 </pre><p>The <code><a href="Network-Socket-SendFile.html#v:runIter">runIter</a></code> function provided by this module is similar, but also returns the total number of bytes sent. </p><p>NOTE: You must not use the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a></code> or the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a></code> <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> after the call to *IterWith has returned. When the *IterWith functions return, the file descriptors may be closed due to finalizers running. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Sent" class="def">Sent</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a>)</td><td class="doc"><p>number of bytes sent this pass and a continuation to send more </p></td></tr><tr><td class="src"><a name="v:WouldBlock" class="def">WouldBlock</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-Posix-Types.html#t:Fd">Fd</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a>)</td><td class="doc"><p>number of bytes sent, Fd that blocked, continuation to send more. NOTE: The Fd should not be used outside the running of the Iter as it may be freed when the Iter is done </p></td></tr><tr><td class="src"><a name="v:Done" class="def">Done</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a></td><td class="doc"><p>number of bytes sent, no more to send </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:runIter" class="def">runIter</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int64">Int64</a><a href="src/Network-Socket-SendFile-Iter.html#runIter" class="link">Source</a></p><div class="doc"><p>A simple function to drive the *IterWith functions. It returns the total number of bytes sent. </p></div></div><h1 id="g:1">Safe functions (recommended) </h1><div class="top"><p class="src"><a name="v:sendFile" class="def">sendFile</a><a href="src/Network-Socket-SendFile.html#sendFile" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></td><td class="doc"><p>The output socket </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path where the input file resides </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The simplest interface. Simply give it an output <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> and the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></code> to the input file. </p></div></div><div class="top"><p class="src"><a name="v:sendFileIterWith" class="def">sendFileIterWith</a><a href="src/Network-Socket-SendFile.html#sendFileIterWith" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></td><td class="doc"><p>The output socket </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path where the input file resides </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>Maximum bytes to send per block (may send less) </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The simplest interface. Simply give it an output <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> and the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></code> to the input file. </p><p>This variant takes a function to drive the iteration loop. See <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> for more information. </p></div></div><div class="top"><p class="src"><a name="v:sendFile-39-" class="def">sendFile'</a><a href="src/Network-Socket-SendFile.html#sendFile%27" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></td><td class="doc"><p>The output socket </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The input file path </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a></td><td class="doc"><p>The offset to start at </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>The number of bytes to send </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>A more powerful interface than sendFile which accepts a starting offset, and the bytecount to send; the offset and the count must be a positive integer. The initial position of the input file handle matters not since the offset is absolute, and the final position may be different depending on the platform -- no assumptions can be made. </p></div></div><div class="top"><p class="src"><a name="v:sendFileIterWith-39-" class="def">sendFileIterWith'</a><a href="src/Network-Socket-SendFile.html#sendFileIterWith%27" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></td><td class="doc"><p>The output socket </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The input file path </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>Maximum bytes to send per block (may send less) </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a></td><td class="doc"><p>The offset to start at </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>The number of bytes to send </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>A more powerful interface than sendFile which accepts a starting offset, and the bytecount to send; the offset and the count must be a positive integer. The initial position of the input file handle matters not since the offset is absolute, and the final position may be different depending on the platform -- no assumptions can be made. </p><p>This variant takes a function to drive the iteration loop. See <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> for more information. </p></div></div><h1 id="g:2">Unsafe functions </h1><div class="doc"><p>These functions are unsafe simply because there is no guarantee that the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></code> used for output is actually bound to a <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code>. If it is not, it will result in a runtime error. </p></div><div class="top"><p class="src"><a name="v:unsafeSendFile" class="def">unsafeSendFile</a><a href="src/Network-Socket-SendFile.html#unsafeSendFile" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc"><p>The output handle </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path where the input file resides </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The unsafe version of sendFile which accepts a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></code> instead of a <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> for the output. It will flush the output handle before sending any file data. </p></div></div><div class="top"><p class="src"><a name="v:unsafeSendFileIterWith" class="def">unsafeSendFileIterWith</a><a href="src/Network-Socket-SendFile.html#unsafeSendFileIterWith" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc"><p>The output handle </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path where the input file resides </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>Maximum bytes to send per block (may send less) </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The unsafe version of sendFile which accepts a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></code> instead of a <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> for the output. It will flush the output handle before sending any file data. </p><p>This variant takes a function to drive the iteration loop. See <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> for more information. </p></div></div><div class="top"><p class="src"><a name="v:unsafeSendFile-39-" class="def">unsafeSendFile'</a><a href="src/Network-Socket-SendFile.html#unsafeSendFile%27" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc"><p>The output handle </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The input filepath </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a></td><td class="doc"><p>The offset to start at </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>The number of bytes to send </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The unsafe version of sendFile' which accepts a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></code> instead of a <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> for the output. It will flush the output handle before sending any file data. </p></div></div><div class="top"><p class="src"><a name="v:unsafeSendFileIterWith-39-" class="def">unsafeSendFileIterWith'</a><a href="src/Network-Socket-SendFile.html#unsafeSendFileIterWith%27" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="Network-Socket-SendFile.html#t:Iter">Iter</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></td><td class="doc"><p>The output handle </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The input filepath </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>The number of bytes to send </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:Offset">Offset</a></td><td class="doc"><p>The offset to start at </p></td></tr><tr><td class="src">-> <a href="Network-Socket-SendFile.html#t:ByteCount">ByteCount</a></td><td class="doc"><p>The number of bytes to send </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> a</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>The unsafe version of sendFile' which accepts a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/GHC-IO-Handle.html#t:Handle">Handle</a></code> instead of a <code><a href="/usr/share/doc/ghc/html/libraries/network-2.3.0.2/Network-Socket.html#t:Socket">Socket</a></code> for the output. It will flush the output handle before sending any file data. </p><p>This variant takes a function to drive the iteration loop. See <code><a href="Network-Socket-SendFile.html#t:Iter">Iter</a></code> for more information. </p></div></div><h1 id="g:3">Utility functions </h1><div class="top"><p class="src"><a name="v:sendFileMode" class="def">sendFileMode</a><a href="src/Network-Socket-SendFile.html#sendFileMode" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>The mode that sendfile was compiled with </p></td></tr></table></div><div class="doc"><p>Returns the mode that sendfile was compiled with. Mainly for debugging use. Possible values are <code>WIN32_SENDFILE</code>, <code>LINUX_SENDFILE</code>, <code>FREEBSD_SENDFILE</code>, <code>DARWIN_SENDFILE</code>, and <code>PORTABLE_SENDFILE</code>. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>