空或QUOT;冲洗"文件描述符没有阅读()?

问题描述:

(注意:这是不会如何刷新一个的write()的问题这是的另一端吧,可以这么说。)

(Note: This is not a question of how to flush a write(). This is the other end of it, so to speak.)

是否有可能空了在读取数据的文件描述符它的没有不得不阅读()呢?你可能不感兴趣的数据,和阅读这一切会因此浪费的空间和周期你可能有更好的用途。

Is it possible to empty a file descriptor that has data to be read in it without having to read() it? You might not be interested in the data, and reading it all would therefore waste space and cycles you might have better uses for.

如果这是不可能的POSIX,做任何操作系统的任何不可移植的方式来做到这一点?

If it is not possible in POSIX, do any operating systems have any non-portable ways to do this?

更新:请注意,我说的的文件描述符不可以

UPDATE: Please note that I'm talking about file descriptors, not streams.

流有fclean可用,这刷新写缓冲区,并返回读缓冲回IO系统

Streams have fclean available, which flushes the write buffer, and returns the read buffer back to the IO system.

http://www.gnu.org/software/你好/手动/的libc /清洁-Streams.html

如果你真的想要做的是跳过字节,重新定位文件指针是正确的行动。刚跳到的字节数,你不想读。

If what you really want to do is skip bytes, repositioning the file pointer is the correct action. Just skip ahead as many bytes as you don't want to read.

http://www.gnu.org/software/hello/manual/libc/File-Position-Primitive.html#File-Position-Primitive