sendfile - transfer data between file descriptors


       #include <unistd.h>



       This  call copies data between file descriptor and another
       file  descriptor  or  socket.   in_fd  should  be  a  file
       descriptor   opened  for  reading.   out_fd  should  be  a
       descriptor opened for writing or a connected socket.  off­
       set  is  a  pointer  to  variable  holding  the input file
       pointer position from which sendfile(2) will start reading
       data. After sendfile finished 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


       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  refer  to  the TCP_CORK option in
       tcp(4) to tune performance.


       If the transfer was succeeded, the number of bytes written
       to out_fd is returned. On error, -1 is returned, and errno
       is set appropriately.


       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.


       sendfile is a new feature in Linux 2.2.

       Other  Unixes  often  implement  sendfile  with  different
       semantics  and  prototypes.  It  should  not  be  used  in
       socket(2), open(2)