United States-English |
|
|
HP-UX Reference > Ssendfile(2)HP-UX 11i Version 3: February 2007 |
|
NAMEsendfile() — send the contents of a file through a socket SYNOPSIS#include <sys/socket.h> sbsize_t sendfile(int s, int fd, off_t offset, bsize_t nbytes, const struct iovec *hdtrl, int flags); DESCRIPTIONThe sendfile() system call transmits the contents of a file associated with the file descriptor fd, plus an optional header and trailer buffers across a socket connection specified by s. sendfile() can be used only when the socket is in a connected state. offset specifies the offset within the file at which to start the file data transfer. nbytes is the number of bytes to be sent from the file. If this parameter is set to zero, data from the offset to the end of the file will be sent. hdtrl points to a two entry iovec structure. See write(2) for a description of the iovec structure. The first entry is for header information. If this pointer is non-NULL, the contents of the buffer are sent before sending any data from the file. The second entry is for trailer information. If this pointer is non-NULL, the contents of the buffer will be sent after the data from the file. If both pointers are NULL, or hdtrl is a NULL pointer, only the specified range of the file will be transferred. At the end of the call, the socket connection will be left completely open for both reading and writing, unless the flags parameter is set to:
NotesIf no buffer space is available to hold the data to be transmitted, sendfile() blocks unless nonblocking mode is enabled. See send(2) for a description of the nonblocking mode behavior. See sendfile64(2) for a description of how sendfile can be used with large file (over 2GB) with 32-bit applications. Note that the types sbsize_t and bsize_t are similar to ssize_t and size_t except they are defined as 64-bit values when compiled with the _FILE_OFFSET_BITS=64 compile flag. See sendfile64(2). RETURN VALUEUpon successful completion, sendfile() returns the number of bytes sent. This includes the header, trailer, and the file contents. Otherwise, -1 is returned and errno is set to indicate the error. ERRORSIf sendfile() fails, errno is set to one of the following values.
|
Printable version | ||
|