Skip to content

Commit

Permalink
documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jun 14, 2011
1 parent f6707d4 commit 7ae9325
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Network/Sendfile/BSD.hsc
Expand Up @@ -15,6 +15,10 @@ import Network.Socket
import System.Posix.IO
import System.Posix.Types (Fd(..), COff)

{-|
Simple binding for sendfile() of MacOS.
Used system calls: open(), sendfile(), and close().
-}
sendfile :: Socket -> FilePath -> FileRange -> IO ()
sendfile sock path range = bracket
(openFd path ReadOnly Nothing defaultFileFlags)
Expand Down
4 changes: 4 additions & 0 deletions Network/Sendfile/Fallback.hs
Expand Up @@ -11,6 +11,10 @@ import Network.Sendfile.Types
import Network.Socket
import qualified Network.Socket.ByteString as SB

{-|
Sendfile emulation using enumerator.
Used system calls: open(), stat(), read(), send() and close().
-}
sendfile :: Socket -> FilePath -> FileRange -> IO ()
sendfile s fp EntireFile =
run_ $ enumFile fp $$ sendIter s
Expand Down
8 changes: 8 additions & 0 deletions Network/Sendfile/Linux.hsc
Expand Up @@ -18,6 +18,14 @@ import System.Posix.Files
import System.Posix.IO
import System.Posix.Types (Fd(..))

{-|
Simple binding for sendfile() of MacOS.
Used system calls:
EntireFile -- open(), stat(), sendfile(), and close()
PartOfFile -- open(), sendfile(), and close()
If the size of the file is unknown when sending the entire file,
specifying PartOfFile is much faster.
-}
sendfile :: Socket -> FilePath -> FileRange -> IO ()
sendfile sock path range = bracket
(openFd path ReadOnly Nothing defaultFileFlags)
Expand Down
4 changes: 4 additions & 0 deletions Network/Sendfile/MacOS.hsc
Expand Up @@ -16,6 +16,10 @@ import Network.Socket
import System.Posix.IO
import System.Posix.Types (Fd(..))

{-|
Simple binding for sendfile() of MacOS.
Used system calls: open(), sendfile(), and close().
-}
sendfile :: Socket -> FilePath -> FileRange -> IO ()
sendfile sock path range = bracket
(openFd path ReadOnly Nothing defaultFileFlags)
Expand Down
3 changes: 3 additions & 0 deletions Network/Sendfile/Types.hs
@@ -1,5 +1,8 @@
module Network.Sendfile.Types where

{-|
File range for 'sendfile'.
-}
data FileRange = EntireFile
| PartOfFile {
rangeOffset :: Integer
Expand Down

0 comments on commit 7ae9325

Please sign in to comment.