#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/sendfile.h>
int main()
{
int s = open("tux", O_RDONLY);
int d = open("output", O_WRONLY | O_CREAT, 0600);
off_t off = 0;
ssize_t size = sendfile(d, s, &off, 10000);
if(size <= 0)
{
perror("sendfile");
}
printf("size = %d, off = %d\n", size, off);
}
原帖由 zhoubug 于 2009-4-24 16:55 发表
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
Presently (Linux 2.6.9): in_fd, must correspond to a file which supports mmap(2)-like operations (i.e.,
it cannot be ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |