Penguin
Annotated edit history of sendfile(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 sendfile - transfer data between file descriptors
2 !!SYNOPSIS
3
4
2 PerryLorier 5 __#include <sys/sendfile.h>__
1 perry 6
2 PerryLorier 7 __ssize_t sendfile(int__ ''out_fd''__, int__ ''in_fd''__, off_t *__''offset''__, size_t__ ''count''__)__
1 perry 8
9 !!DESCRIPTION
2 PerryLorier 10 This call copies data between one file descriptor and another. Either or both of these file descriptors may refer to a socket (but see below). ''in_fd'' should be a file
11 descriptor opened for reading and ''out_fd'' should be a descriptor opened for writing. ''offset'' is a pointer to a variable holding the input file pointer position from
12 which sendfile(2) will start reading data. When sendfile(2) returns, this variable will be set to the offset of the byte following the last byte that was read. ''count'' is the number of bytes to copy between file descriptors.
1 perry 13
2 PerryLorier 14 Because this copying is done within the kernel, sendfile(2) does not need to spend time transferring data to and from user space.
1 perry 15
16 !!NOTES
2 PerryLorier 17 Sendfile does not modify the current file pointer of ''in_fd'', but does for ''out_fd''.
1 perry 18
2 PerryLorier 19 If you plan to use sendfile for sending files to a TCP socket, but need to send some header data in front of the file contents, please see the __TCP_CORK__ option in tcp(7) to minimize the number of packets and to tune performance.
1 perry 20
2 PerryLorier 21 Presently the descriptor from which data is read cannot correspond to a socket, it must correspond to a file which supports mmap(2)-like operations.
1 perry 22
23 !!RETURN VALUE
2 PerryLorier 24 If the transfer was successful, the number of bytes written to ''out_fd'' is returned. On error, -1 is returned, and ''errno'' is set appropriately.
1 perry 25
26 !!ERRORS
2 PerryLorier 27 ;[EBADF]: The input file was not opened for reading or the output file was not opened for writing.
28 ;[EINVAL]: Descriptor is not valid or locked.
29 ;[ENOMEM]: Insufficient memory to read from ''in_fd''.
30 ;[EIO]: Unspecified error while reading from ''in_fd''.
1 perry 31
32 !!VERSIONS
2 PerryLorier 33 sendfile(2) is a new feature in Linux 2.2. The include file <sys/sendfile.h> is present since glibc 2.1.
1 perry 34
2 PerryLorier 35 Other Unixes often implement sendfile(2) with different semantics and prototypes. It should not be used in portable programs.
1 perry 36
37 !!SEE ALSO
38 socket(2), open(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 9 times)