Home > Programming > sendfile() and splice()

sendfile() and splice()

Last night searching for information about how to use splice() described as “an innovative I/O method which was added in Linux-2.6.17, based in a in-kernel buffer that the user has control over, where splice() moves data to/from the buffer from/to an arbitrary file descriptor with splice(), while “tee()” copies the data in one buffer to another”, I realized that’s don’t exist good examples about how to use it as a replacement for sendfile(),  two hours ago reading about some kernel commits I found that Linux-2.6.23 has changed the original sendfile() implementation by splice() internally:

“For the particular case of sending the data from a file descriptor to a fd socket, there’s been always the sendfile() syscall. splice() however is a generic mechanism, not just limited to what sendfile(). In other words, sendfile() is just a small subset of what splice can do, splice obsoletes it. In Linux 2.6.23, the sendfile() mechanism implementation is killed, but the API and its functionality is not removed, it’s instead implemented internally with the splice() mechanisms.”

Resume: don’t waste time using splice in your code to send files through sockets…it’s already done!

Link: http://kernelnewbies.org/Linux_2_6_23#head-c8fd2455c44d9559429c0f72dbc85cd54a62470d

Categories: Programming Tags:
  1. No comments yet.
  1. No trackbacks yet.