This module provides cross-platform wrapper for sendfile() syscall.
Procs
proc sendfile(outfd, infd: int; offset: int; count: var int): int {....raises: [], tags: [].}
-
Copies data between file descriptor infd and outfd. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.
infd should be a file descriptor opened for reading and outfd should be a descriptor opened for writing.
The infd argument must correspond to a file which supports mmap(2)-like operations (i.e., it cannot be a socket).
offset the file offset from which sendfile() will start reading data from infd.
count is the number of bytes to copy between the file descriptors. On exit count will hold number of bytes actually transferred between file descriptors. May be >0 even in the case of error return, if some bytes were sent before the error occurred.
If the transfer was successful, the number of bytes written to outfd is stored in count, and 0 returned. Note that a successful call to sendfile() may write fewer bytes than requested; the caller should be prepared to retry the call if there were unsent bytes.
On error, -1 is returned.
Source Edit