开发者

Differnce between linux write and sendfile syscall

Im programming webserver (C), which should send big files. My question is: What are the main differences in two syscalls: write and sendfile. Does sendfile depends on size of socket system buffer? I noticed that write often writes less then I requested.

For example, if got many requests for one file: should i open it, copy into memory and use write, or maybe I can do sendfile for each 开发者_开发百科client?

Thanks in advance for all answers.


Please read sendfile(2).

sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.

Regarding return value any of write/read/senfile calls do not guarantee that entire block of data is written/read/sent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜