Is it possible to splice() from a socket to a buffer with "zero-copy"? If yes, how?
The example code I found for splice() has two steps (splice example code):
Is there always going to be an intermediary step of using a pipe (i.e. you can't do a zero-copy operation into a buffer in user space)?
@yeyo has answer this question in the question's comments IMO but did not provide a timely answer. So I will summarize:
You can not splice() from a socket to a buffer with “zero-copy”.
The reason you can't use splice() is because splice() "requires either the source or destination to be a pipe". In other words when the source is a socket then the destination must be a pipe because of the API's restrictions ('either the source or destination or both must be a pipe').
That answers the yes or no question but not the "why".
I still had questions about the "why" or specifically:
Linus Torvalds answers those questions directly in the link and his answer seems clear and concise to me (if not with a little studying of what he writes): http://yarchive.net/comp/linux/splice.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With