sendfile-0.6.1: A portable sendfile librarySource codeContentsIndex
Network.Socket.SendFile
Contents
Safe functions (recommended)
Utility functions
Description

A cross-platform wrapper for sendfile -- this implements an available operating-system call if supported, otherwise it falls back to a portable haskell implementation.

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.

For consistent read/write behavior with either sendFile' or unsafeSendFile', the input handle should be opened in Binary mode rather than Text mode.

Synopsis
type ByteCount = Integer
type Offset = Integer
sendFile :: Socket -> FilePath -> IO ()
sendFile' :: Socket -> FilePath -> Offset -> ByteCount -> IO ()
unsafeSendFile :: Handle -> FilePath -> IO ()
unsafeSendFile' :: Handle -> FilePath -> Offset -> ByteCount -> IO ()
sendFileMode :: String
Documentation
type ByteCount = IntegerSource
The length (in bytes) which should be sent
type Offset = IntegerSource
The file offset (in bytes) to start from
Safe functions (recommended)
sendFileSource
:: SocketThe output socket
-> FilePathThe path where the input file resides
-> IO ()
The simplest interface. Simply give it an output Socket and the FilePath to the input file.
sendFile'Source
:: SocketThe output socket
-> FilePathThe input file handle
-> OffsetThe offset to start at
-> ByteCountThe number of bytes to send
-> IO ()
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.
unsafeSendFileSource
:: HandleThe output handle
-> FilePathThe path where the input file resides
-> IO ()
The unsafe version of sendFile which accepts a Handle instead of a Socket for the output. It will flush the output handle before sending any file data.
unsafeSendFile'Source
:: HandleThe output handle
-> FilePathThe input filepath
-> OffsetThe offset to start at
-> ByteCountThe number of bytes to send
-> IO ()
The unsafe version of sendFile' which accepts a Handle instead of a Socket for the output. It will flush the output handle before sending any file data.
Utility functions
sendFileModeSource
:: StringThe mode that sendfile was compiled with
Returns the mode that sendfile was compiled with. Mainly for debugging use. | Possible values are WIN32_SENDFILE, LINUX_SENDFILE, FREEBSD_SENDFILE, | DARWIN_SENDFILE, and PORTABLE_SENDFILE.
Produced by Haddock version 2.5.0