Safe Haskell | Safe-Infered |
---|
This library implements most efficient socket to socket data transfer loops for proxy servers on each operating system.
On Linux, it uses and exposes the zero-copy splice()
system call:
http://kerneltrap.org/node/6505.
On other operating systems, it currently falls back to a portable Haskell
implementation – which first allocates a constant-sized memory buffer in user
address, then enters an inner loop which uses hGetBufSome
and hPutBuf
on this user-space buffer. This avoids tony of tiny
allocations as might otherwise be caused by recv
and sendAll
from the bytestring
package.
Cross-platform API for Socket to Socket Data Transfer Loops
splice
is the cross-platform API for continous, uni-directional
data transfer between two network sockets.
It is an infinite loop that is intended to be used with
forkIO
:
void . forkIO . try_ $ splice 1024 sourceSocket targetSocket void . forkIO . try_ $ splice 1024 targetSocket sourceSocket
Pipes data from one socket to another in an infinite loop.
On Linux this uses the splice()
system call and eliminates copying
between kernel and user address spaces.
On other operating systems, a portable Haskell implementation utilizes a user space buffer.
type ChunkSize = ChunkSizeSource
The numeric type to recommend chunk sizes for moving data between sockets
used by both zero-copy and portable implementations of splice
.
Indicates whether splice
uses zero-copy system calls or the portable user
space Haskell implementation.