I've got a situation where I might want to "skip" data in a pipe or socket for processing. I could of course read() the data into a buffer and just discard it, but is there a more efficient way? Perhaps something like sendfile that would work with a non-mmappable source?
You need to read
the data. What you do with it is up to you, so you can skip over parts, or whatever.
Without reading it the data stays stuck in the read buffer. The recommended way to get it out of the buffer is to read it.
That being said, if you read something that indicates that all subsequent data will be of no use, you could just close the connection and be done with it.
I'm not sure what you mean about "efficient" because reading from a buffer is probably not the performance bottleneck in your code.
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