*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> sendfile (2)              
Title
Content
Arch
Section
 

SENDFILE(2)

Contents


NAME    [Toc]    [Back]

       sendfile - transfer data between file descriptors

SYNOPSIS    [Toc]    [Back]

       #include <sys/sendfile.h>

       ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)

DESCRIPTION    [Toc]    [Back]

       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  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 which send-
       file() will start reading data.	When sendfile() 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.

       Because this copying is done within the	kernel,  sendfile()  does  not
       need to spend time transferring data to and from user space.

NOTES    [Toc]    [Back]

       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(7) to minimize the number of packets and to tune
       performance.

       Presently the descriptor from which data is read cannot correspond to a
       socket, it must correspond to a file which supports mmap()-like	operations.


RETURN VALUE    [Toc]    [Back]

       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.

ERRORS    [Toc]    [Back]

       EBADF  The input file was not opened for reading or the output file was
	      not opened for writing.

       EINVAL Descriptor is not valid or locked.

       ENOMEM Insufficient memory to read from in_fd.

       EIO    Unspecified error while reading from in_fd.

VERSIONS    [Toc]    [Back]

       sendfile is a new feature in Linux 2.2.	The  include  file  <sys/sendfile.h>
 is present since glibc2.1.

       Other Unixes often implement sendfile with different semantics and prototypes.
 It should not be used in portable programs.

SEE ALSO    [Toc]    [Back]

      
      
       socket(2), open(2)



Linux Man Page			  1998-12-01			   SENDFILE(2)
[ Back ]
 Similar pages
Name OS Title
dup Tru64 Control open file descriptors
dup2 Tru64 Control open file descriptors
fcntl Tru64 Control open file descriptors
poll HP-UX monitor I/O conditions on multiple file descriptors
poll Tru64 Monitor conditions on multiple file descriptors
poll HP-UX monitor I/O conditions on multiple file descriptors
VkInput IRIX Encapsulation class for input callbacks on file descriptors
devpoll.h Tru64 Device driver for a fast poll on many file descriptors
maxfiles_lim HP-UX hard maximum number of file descriptors per process
poll Tru64 Device driver for a fast poll on many file descriptors
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service