Unix Pipes are used in inter-process communication. A pipe as name suggests provides a unidirectional flow of information. Data flows from one end to another.
Message queue allows to share messages by a sender process to another process (es). A message queue is implemented as a linked list of messages and stored within kernel. Each message has a unique message queue identifier. The kernel keeps a record of message queues present in the system.
The following are some of the important differences between Unix Pipes and Message Queues.
|Sr. No.||Key||Pipe||Message Queue|
|1||Concept||The pipe is the Unix IPC form to provide a flow of information in one direction.||Message Queue is a System VIPC form to store a list of messages.|
|2||Creation||A pipe can be created using pipe() function which returns two file descriptors, one is for reading and another is for writing.||A message queue is created using msgget() function which returns a queue identifier.|
|3||Direction||The pipe is unidirectional.||A message queue is bidirectional.|
|4||Data Fetching||Data can be fetched in FIFO, First In First Out manner.||Data can be fetched in any order.|
|5||Priorities||Priorities are not present in pipes.||A message can have a priority by attaching a priority number to type(s) of the message(s).|
|6||Receiver||For a pipe to function, sender and receiver processes should be present to wait for messages to be written and read in a pipe.||In a message queue, a writer process can write a message and exit. A reader process can read a message later.|
|7||Persistence||A pipe is deleted from the system if there is no linked receiver/sender process is present.||A message queue remains active in the system until explicitly deleted by some process.|
|8||Message Size||A pipe message size can be up to 4096 Bytes.||A message queue message size can be up to 8192 Bytes.|