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

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

sendfile(2)

Contents


NAME    [Toc]    [Back]

       sendfile - Send the contents of a file through a socket

SYNOPSIS    [Toc]    [Back]

       #include <sys/socket.h>

       ssize_t sendfile(
               int socket,
               int fd,
               off_t offset,
               size_t nbytes,
               const struct iovec *hdtrl,
               int flags );

PARAMETERS    [Toc]    [Back]

       Specifies  the socket file descriptor.  Specifies the file
       descriptor of the file that contains the  contents  to  be
       sent.   Specifies  the  point  within the file (offset) at
       which to start the data transfer.  Specifies the number of
       bytes  to  send  from  the file. If the value is zero (0),
       data from the offset to the  end  of  the  file  is  sent.
       Points to a two-entry array of iovec structures. The first
       entry contains header information. If the  iov_len  member
       is  non-zero,  the  contents of the buffer are sent before
       any data from the file.

              The second entry contains trailer  information.  If
              the iov_len member is non-zero, the contents of the
              buffer are sent after any data from the file.

              If both iov_len members are NULL or if hdtrl  is  a
              NULL  pointer, only the specified file contents are
              transferred.

              See write(2) for information on  the  iovec  structure.
  Not currently used.

DESCRIPTION    [Toc]    [Back]

       The  sendfile() function sends the specified contents of a
       file only through a connected socket.

RETURN VALUES    [Toc]    [Back]

       Upon  successful  completion,  the   sendfile()   function
       returns  the  number  of bytes sent, including the header,
       trailer,  and  file  contents.  Otherwise,  the   function
       returns  a  value  of  -1  and  sets errno to indicate the
       error.

ERRORS    [Toc]    [Back]

       If the sendfile() function fails, errno may be set to  one
       of  the  following  values:  Non-blocking  I/O  is enabled
       (O_NONBLOCK), and the  requested  operation  would  block.
       Addresses  in  the specified address family cannot be used
       with this socket.  The socket parameter or file descriptor
       is  not  valid.  The hdtrl parameter is not valid or there
       is an invalid pointer in the iovec  structure.   A  signal
       interrupted  sendfile before any data was transmitted.  If
       some data was transmitted, the function returns the number
       of  bytes sent before the interrupt and does not set errno
       to [EINTR].  The offset or flags parameter is invalid.

              The hdtrl parameter,  or  a  length  in  the  iovec
              structure  is invalid.  There is insufficient space
              in the socket buffer.  The system did not have sufficient
 memory to fulfill the request.  A socket is
              connection-oriented but is not connected,  has  not
              completed the connect sequence with its peer, or is
              no longer connected to its peer.  The socket parameter
 refers to a file, not a socket.  The socket is
              not a TCP socket.   You  attempted  to  send  on  a
              socket  that  was  connected, but either the remote
              peer or localhost has closed the connection. If the
              process  does  not  have  a signal handler for this
              signal (SIGPIPE), the default action is  to  terminate
  the  process.  The socket is marked nonblocking,
 and the requested operation would block.

SEE ALSO    [Toc]    [Back]

      
      
       Functions:  connect(2),  read(2),  send(2),   shutdown(2),
       socket(2), write(2), tcp(7).



                                                      sendfile(2)
[ Back ]
 Similar pages
Name OS Title
sendfile64 HP-UX send the contents of a Large File through a socket
sendfile FreeBSD send a file to a socket
DtEditorReplaceFromFile HP-UX replace a portion of the contents of a DtEditor widget with the contents of a file
sendmsg OpenBSD send a message from a socket
send OpenBSD send a message from a socket
send FreeBSD send a message from a socket
sendmsg FreeBSD send a message from a socket
send NetBSD send a message from a socket
send IRIX send a message from a socket
sendto NetBSD send a message from a socket
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service