SENDFILE(2) Linux Programmer's Manual SENDFILE(2) NAME sendfile - transfer data between file descriptors SYNOPSIS #include <unistd.h> int sendfile(int out_fd, int in_fd, off_t *offset, size_t count) DESCRIPTION This call copies data between file descriptor and file descriptor or socket. in_fd should be file descriptor opened for reading. out_fd should be descriptor opened for writing or connected socket. offset is a pointer to variable holding input file pointer position from which sendfile(2) will start reading data. After sendfile fin- ished this variable points to the byte after the last byte that was read. count is number of bytes to copy between file descriptors. NOTES Sendfile does not modify the current file pointer of in_fd, but does for out_fd. 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(4) RETURN VALUE If the transfer was succeeded, number of bytes written to out_fd is returned. On error, -1 is returned, and errno is set appropriately. ERRORS EBADF Input file was not opened for reading or output file was not opened for writing. EINVAL Descriptor is not valid or locked. ENOMEM Insufficient memory for reading from in_fd EIO Unspecified error while reading from in_fd VERSIONS sendfile(2) is a new feature in Linux 2.2 SEE ALSO socket(2), open(2) Linux Man Page 1 Dec 1998 1