从实时文件中读取C(文件大小不断增长) [英] C reading from a live file ( file keep growing in size )
本文介绍了从实时文件中读取C(文件大小不断增长)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个正在实时录制的应用程序,捕获文件的大小一直在增长 使用fread()和feof(),但是feof()早就打破了循环,那么从流中读取数据的最佳技术是什么
I have an application that is recording live , the capture file keep growing in size using fread() and feof() , but feof() is breaking the loop early , so what's the best technique to keep reading from the stream
- 我应该等待,然后才能推进文件流吗?
- 我应该再次打开文件并通过计算读取的字节总数前进到位置吗?
- 也许还有别的吗?
代码必须读取文件,构建数据包并发送 固定大小的文件可以很好地进行打包和发送
the code will have to read the file , build a packet and send it packaging and sending is going well with fixed size files
推荐答案
我将监视文件(类似于select(2)
).收到通知后,我会尽可能地read
然后再次等待.
I would monitor the file (something like select(2)
). When notified, I would read
as much as possible then wait again.
这篇关于从实时文件中读取C(文件大小不断增长)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文