Skip to content

Commit

Permalink
adding doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jun 21, 2012
1 parent 9aa5525 commit 36ff3c4
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Network/Sendfile/BSD.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import System.Posix.Types
entire :: COff
entire = 0

{-|
Simple binding for sendfile() of MacOS.
-- |
-- Simple binding for sendfile() of BSD and MacOS.
--
-- - Used system calls: open(), sendfile(), and close().
--
-- 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 bofore waiting the socket to be ready for writing.

- Used system calls: open(), sendfile(), and close().
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 bofore waiting the socket to be ready for writing.
-}
sendfile :: Socket -> FilePath -> FileRange -> IO () -> IO ()
sendfile sock path range hook = bracket setup teardown $ \fd ->
alloca $ \sentp -> do
Expand Down Expand Up @@ -66,6 +66,19 @@ sendloop dst src off len sentp hook = do

----------------------------------------------------------------

-- |
-- Simple binding for sendfile() of BSD and MacOS.
--
-- - Used system calls: open(), sendfile(), and close().
--
-- The fifth header is also sent with sendfile(). If the file is
-- small enough, the header and the file is send in a single TCP packet.
--
-- 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 bofore waiting the socket to be ready for writing.

sendfileWithHeader :: Socket -> FilePath -> FileRange -> IO () -> [ByteString] -> IO ()
sendfileWithHeader sock path range hook hdr =
bracket setup teardown $ \fd -> alloca $ \sentp ->
Expand Down

0 comments on commit 36ff3c4

Please sign in to comment.