管道与味精队列 [英] Pipe vs msg queue

查看:67
本文介绍了管道与味精队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

消息队列和Linux中的管道有什么区别?

What is the difference between message queues and a pipe in Linux?

推荐答案

在我脑海中,假设您谈论的是posix消息队列(不是SysV队列):

Off the top of my head and assuming you talk about posix message queues (not the SysV ones):

  • 管道不受大小限制,消息队列不受限制.
  • 管道可以使用文件描述符集成到系统中,消息队列具有其自己的功能集,尽管linux在mqd_t上支持select()poll()epoll()和朋友.
  • 管道一旦关闭,则需要双方进行一定程度的合作以重新建立它们,消息队列可以在任一侧关闭并重新打开,而无需另一侧的配合.
  • 管道是扁平的,就像流一样,为了强加一个消息结构,您必须在两侧都实现一个协议,消息队列已经面向消息,无需费心就可以得到例如第五条消息.队列.
  • Pipes aren't limited in size, message queues are.
  • Pipes can be integrated in systems using file descriptors, message queues have their own set of functions, though linux supports select(), poll(), epoll() and friends on the mqd_t.
  • Pipes, once closed, require some amount of cooperation on both sides to reestablish them, message queues can be closed and reopened on either side without the coorporation of the other side.
  • Pipes are flat, much like a stream, to impose a message structure you would have to implement a protocol on both sides, message queues are message oriented already, no care has to be taken to get, say, the fifth message in the queue.

这篇关于管道与味精队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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