简体   繁体   English

使用消息队列C发送文件内容

[英]send file content with a message queue C

I'm looking for the best way to read a file and send the contents via a message queue. 我正在寻找读取文件并通过消息队列发送内容的最佳方法。 I tried to read the file line by line and insert the contents of the file into an array, but maybe not the best way. 我试图逐行读取文件并将文件内容插入数组,但是可能不是最好的方法。 I was wondering is there another way, perhaps it's better to send the whole file and then read it to the process that receives it. 我想知道还有另一种方法,也许最好发送整个文件,然后将其读取到接收它的进程中。 Do you have any suggestions? 你有什么建议吗? thanks in advance. 提前致谢。

As I read it there is hardly a difference between the per line array send method and the full file send method. 在我阅读本文时,每行数组发送方法和完整文件发送方法之间几乎没有区别。 You are only spreading the load on the network that way. 您只是通过这种方式分散了网络上的负载。 Unless the receiving party has a limited CPU and memory cache it does not increase the overall system performance. 除非接收方的CPU和内存缓存有限,否则不会提高整体系统性能。

I would suggest looking into parsing the whole file for relevant data. 我建议您考虑分析整个文件以获取相关数据。 Then send this new data via a message queue. 然后通过消息队列发送此新数据。 Unless of course the program reading the file has limited resources, while the receiving end has enough resources and the traffic load on the network isn't an issue. 当然,除非读取文件的程序具有有限的资源,而接收端具有足够的资源,并且网络上的流量负载不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM