O nás     Inzerce     KontaktSpolehlivé informace o IT již od roku 2011
Hledat
Nepřehlédněte: Nejlepší IT: Pozoruhodné IT produkty pro rok 2024 podruhé
Správa dokumentů
Digitální transformace
Informační systémy
Hlavní rubriky: Informační systémy, Mobilní technologie, Datová centra, Sítě, IT bezpečnost, Software, Hardware, Zkušenosti a názory, Speciály

Pozoruhodné IT produkty 2024 podruhé
E-knihy o IT zdarma
Manuál Linux
[Linux manuál]

sendfile: přenos dat mezi deskriptory souborů

Originální popis anglicky: sendfile - transfer data between file descriptors

Návod, kniha: Linux Programmer's Manual

STRUČNĚ

#include <sys/sendfile.h>
 
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);

POPIS / INSTRUKCE

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 sendfile() 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

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.
 

NÁVRATOVÁ HODNOTA

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.
 

CHYBY / ERRORY

EAGAIN
Non-blocking I/O has been selected using O_NONBLOCK and the write would block.
EBADF
The input file was not opened for reading or the output file was not opened for writing.
EFAULT
Bad address.
EINVAL
Descriptor is not valid or locked.
EIO
Unspecified error while reading from in_fd.
ENOMEM
Insufficient memory to read from in_fd.

VERSIONS

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.

SOUVISEJÍCÍ

open(2), socket(2)
1998-12-01 Linux Man Page
©2011-2024 BusinessIT.cz, ISSN 1805-0522 | Názvy použité v textech mohou být ochrannými známkami příslušných vlastníků.
Provozovatel: Bispiral, s.r.o., kontakt: BusinessIT(at)Bispiral.com | Inzerce: Best Online Media, s.r.o., zuzana@online-media.cz
O vydavateli | Pravidla webu BusinessIT.cz a ochrana soukromí | Používáme účetní program Money S3 | pg(8152)