空或QUOT;冲洗"文件描述符没有阅读()? [英] Empty or "flush" a file descriptor without read()?

查看:131
本文介绍了空或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.

<一个href=\"http://www.gnu.org/software/hello/manual/libc/File-Position-Primitive.html#File-Position-Primitive\" rel=\"nofollow\">http://www.gnu.org/software/hello/manual/libc/File-Position-Primitive.html#File-Position-Primitive

这篇关于空或QUOT;冲洗&QUOT;文件描述符没有阅读()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆